Works on Dev Sys, but No Where Else...

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Okay,

I'm not exactly sure why this is occurring, and I believe it has something to do with Microsoft Office automation. My application basically Automates Word, Excel, and Outlook for use with facilitating many of my Team's daily functions. As a stickler about not doing tedious labor, I prefer to use computers to automate tasks I'd rather not use a pen for, and thus my Word Documents and Excel sheets can be populated via COM.

Granted, I am using SharpDevelop Open Source .Net IDE, but I figure I'd ask here as well as over there, to find out what exactly is causing the glitch. I run the program on my computer, the development system, all the time, and never have a problem. But now I'm getting ready to deploy, and it won't ever start on other systems.

Now, I use a few assemblies in my program, Shell32, Microsoft Word 11.0, Microsoft Excel 11.0, and Microsoft Outlook 11.0, and the compiler tends to include these "Interop.Word.dll" and other "Interop" dll files in my bin/Release directory. If those dll's are present the program runs on my system fine. If not, the program fails. However, if I copy those dll's to another system they don't work and I am curious as to why? Isn't there a way to access the COM functionality of Shell32 and specific Office Libraries without being machine specific? Is there some sort of "CopyRight" liscence code that is being compiled into the Dlls and thus not allowing the application to run?

Any help would be most appreciated.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
Recommended usage of Office automation library is through the official Primary Interop Assemblies. You download, install and reference these, done correctly your application will not generate its own interop files, so these files will not output to build path. The PIAs are installed to GAC, same should be done at clients to use same interops. The interop are "mapping" files that ensures correct calls to the Office libraries. The full Office applications needs to be installed for it to work, both at development machine and clients.
About PIAs: Primary Interop Assemblies (PIAs) and Interop Assemblies (IAs) [Office 2003 SDK Documentation]
Installing and Using the Office 2003 Primary Interop Assemblies, with download link.
Working with the Office XP Primary Interop Assemblies, discusses deployment in Distributing Solutions section, for O10 but valid for O11 also.
 
Just curious, but is there a similar thing for C:\Windows\Shell32.dll

I include that one via COM, but i'm curious if the included Interop.Shell32.dll will conflict with other Windows XP versions. (i know the xp is version 6 where 2kpro is version 5).

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
There isn't. I think if the methods you call have same signatures it should work, but don't know for sure.
 
Well,

I found that I didn't even need to use the Interop.Shell32.DLL, which is nice since I kind of thought the existence of the interop dlls defeated the purpose of COM.

However, my application still will not even start up when the application is run on another system. when i copy it over to the other system, it consistently has a Invalid Operation Exception.

I put a Try - Catch block in my MainFormLoad() event handler, and my exception catcher is not triggering, which tells me the glitch lies somewhere before my MainForm is even loaded. This does not bode well for the "ease" of VB.NET, since now, I cannot even do something as fundamental as "deploy" my application to another system, because I have no idea what the error is. INvalid Operation is none to descriptive. How/where/what can i do to find out what is causing the invalid operation when I run the exe on another system?

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
Last edited:
Well,

I found that I didn't even need to use the Interop.Shell32.DLL, which is nice since I kind of thought the existence of the interop dlls defeated the purpose of COM.
The only way I see that is possible is with CreateObject("Shell.Application") and late binding. Otherwise if 'copy local' is set False for the reference there is build error because the interop isn't signed (and if it was possible that interop still would need to be available (GAC)).

The ease of VB.Net deployment is using a proper installer, if you do a xcopy deployment manually the minimum requirement is to copy everything in build path and make sure Framework is installed basically, but there could be other prerequisites also, you know best yourself if your application has special dependencies.
 
That's the issue. There aren't really any dependencies.
  1. The Microsoft PIAs - Installed on Both Systems. I never set any paths or nothing on my system, so there should be no need to do so on his. I just installed, and then included the reference in the application, and voila it works.
  2. Shell32.dll] - Originally, I had just included it in my references, and it defaultly "copied local", thus creating the Interop.Shell32.dll in my /bin/release directory. But, on a whim, i tested the application by compiling the Shell32 reference with the "Local Copy" set to false. And it worked fine on my system, no matter what directory i Moved teh compiled EXE to.
  3. Final Reference - There are none. WHen I compile the application, i get a single EXE, no dependencies, which is the way I like it. There is no real reason for this application to come with excessive DLLs. It's 480K compiled executable, so that's fine for what it is supposed to do.

So given these points above the only things that should need to be done are:
Verify it is Windows XP (XP comes with Shell32.DLL 6.0)
.Net Framework 1.1 Installed
.Net Framework 2.0 Installed (this is what it is compiled under)
MSO 2003 PIA's installed.

With this set up it still doesn't work, so my question is, how do i find out what dependencies or other errors the program "thinks" it needs that i did not explicitly add into it?

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner


Project Wide Imports
  • System
  • System.Collections
  • System.Collections.Generic
  • System.Diagnostics
  • System.Drawing
  • System.Windows.Forms.
  • Microsoft.VisualBasic
Project References
  • Microsoft.Office.Interop.Excel
  • Microsoft.Office.Interop.Word
  • Microsoft.Office.Interop.Outlook
  • Shell32
  • System
  • System.Data
  • System.Drawing
  • System.Windows.Forms
  • System.Xml
Imports From Source Files
  • System.IO
  • System.RunTime.CompilerServices
  • System.RunTime.InteropServices
  • System.Collections
  • System.Collections.Generic
  • System.Collections.ObjectModel
  • System.Net
  • System.Net.Sockets
  • System.Text
  • System.Text.ASCIIEncoding
  • System.Reflections
  • System.Drawing
  • System.Windows.Forms
  • Shell32
  • Microsoft.Win32
  • Microsoft.Office.Interop
  • Microsoft.Office.Interop.Excel
  • Microsoft.Office.Interop.Word
  • Microsoft.Office.Interop.Outlook

So, these are all my program dependencies. I can't see of any reason this shouldn't work on any .net 2.0 system with the appropriate office PIA's installed.
 
Last edited:
I think the Shell32 interop is the problem. I figured out how to allow 'copy local=False', I had to sign the application. But this makes application break when a Shell32 type is used, this error:
System.IO.FileNotFoundException: Could not load file or assembly 'Interop.Shell32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=53b79cde976068ae' or one of its dependencies. The system cannot find the file specified.
Are you sure your app runs on dev machine without the interop file? You have to actually make a call to this library before the error occurs.
 
Actually, Yea, i just discovered that about the Shell32 dll, so I had to put it back to Local Copy: True. However, this still does not explain the "Invalid Operation" exception at load time on non-dev systems.
 
WHo knows...nobody knows...

Well,

I can't figure it but it just won't work. THere isn't a damn thing in this program that should be so COMPUTER specific, and until I can find a way for the error to reciprocate on my system, or find a location within the program code to insert an exception trap, i'll never know.

I really feel like i've wasted 5 months development on a language that doesn't effing work. Delphi - Compile run, every time. C++, compile run every time. VB.NET - well, you might get it to run, if your lucky. And if not, there's no way to fix it.

I even downloaded VisualBasic Express, compiled, published and everything with it. Same exact problem, and that is supposed to seek out what i need to publish.

*Shrug*
 
When you listed everything you checked out in post 8 you didn't mention if same Office version was installed at client. You did catch this requirement?

As for VB.Net (any .Net language if you wish, including C++) in general I see few problems with it. There is quite a lot of discussion and questions asked at forums like this all around the internet, but in 99.99% of cases caused by lack of knowledge and understanding. (and likely some the urge to chat/argue ;)) That's how I see it after reading most of the ~19000 threads here, and a lot more at other forums.

Your application has only two issues external to .Net, Office automation and Shell automation. There are some traps with Office, but I think we have resolved the basics here with Office+PIA, with working code and correct O+PIA installed at client there should be no problem with this. The Shell32 is another issue, I have no way to verify this regarding versioning. If it don't otherwise sort out you have to try without this, if not for other reason than to check it out. I did some research on the internet regarding Shell32 versioning and deployment but were not able to find anything related this issue.
 
When you listed everything you checked out in post 8 you didn't mention if same Office version was installed at client. You did catch this requirement?
Yes, i did verify that even before I knew about the Interop PIAs. I am quite familiar with COM and use it all the time in my Delphi Win32 Code (not .net) and thus I knew that most likely, develping with Office 11 (2003) the code would have issue with say office 2000 or 2002. So I verified that. I also wondered if the .Net 3.5 package install on the client system would be affecting this as well. However, upon install the VisualBasic Express IDE, .NET 3.5 was installed on my system as well, so I subsequently determined that could not be the issue.

As for VB.Net (any .Net language if you wish, including C++) in general I see few problems with it. There is quite a lot of discussion and questions asked at forums like this all around the internet, but in 99.99% of cases caused by lack of knowledge and understanding. (and likely some the urge to chat/argue ;)) That's how I see it after reading most of the ~19000 threads here, and a lot more at other forums.
Granted. I had little patience, and I find that most forums I go to, I tend to ask questions that NEVER get any response. Even so much as an admin or moderator commenting to me that I either need to clarify my question, or that nobody really knows the answer. however, most of my frustration comes from the lack of knowledge and understanding, as you say, and I know. I began developing in .NET less than 6 months ago, so I am very new to the language. However, I've jumped from Delphi, to C++, to VBA, to perl, java, back and forth, and though my code in the "new" language (delphi is my primary) is not perfect, and often lacking the streamlined panache someone experienced with the language would write, it still works.
A Javascript applet i'm working on still works, but not exactly the way I wanted to, or the C++ modification i made to a Game DLL doesn't exactly do what I thought it should - but the fact remains they still work.

My experience with .NET has been a turbulent one, but in the end, when I've worked with other languages and platforms, when I've compiled my EXE it would run on another system with no question. Some of my 'specific' code calls might cause a glitch, but the application would still start. Compile, Copy, run - should work.
Your application has only two issues external to .Net, Office automation and Shell automation. There are some traps with Office, but I think we have resolved the basics here with Office+PIA, with working code and correct O+PIA installed at client there should be no problem with this. The Shell32 is another issue, I have no way to verify this regarding versioning. If it don't otherwise sort out you have to try without this, if not for other reason than to check it out. I did some research on the internet regarding Shell32 versioning and deployment but were not able to find anything related this issue.

As for regards to "external" issues, I do not believe these are the problems. For one, I removed all Office Interop Dependencies. Every reference to Word.Document, Word.Cell, Excel.Worksheet, Excel.Range, etcetera i converted to a generic Object. This is COM, there is not need for an Interop DLL to access COM. The interop stuff, as far as I could tell, was only providing real time type information. And you know what it worked. My computer never noticed the lack of the Interop DLLs.
As well, I removed the Shell32 Interop dll, (still keeping it included in the program references) and found the program ran, until the first time my application made a shell32 call, and then it came up with an error. This was on my system as well. So, should the problem be related to the Shell32, the error should not have occurred until later the application usage.
If the error was Office+PIA related, it should have gone away when I removed the necessity for them to be installed. (I have subsequently returned them to the application once I discovered the program still failed without them involved).

Here is my awareness of the problem.
VB.NET:
        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.UniversalTool.UnivForm
        End Sub
This is the My Project - Application.Designer.vb file. Sets the application main form to my "main form".
VB.NET:
  Public Sub New()
      Me.InitializeComponent()
  End Sub
this is UnivForm.New() the constructor of my form and subsequently the main interface of the application.
VB.NET:
  Public stColors As ColorTableClass
  Public ClientList As ClientListClass
  Public Preferences As UnivPreferences
  Public ClientForm As ClientInfoForm
  Public WithEvents FTPFrm As FTPForm
  Public WithEvents ActiveJobs As CPMJobListClass
  Private WithEvents KeyHook As WindowsHookLib.LLKeyboardHook
  Private WithEvents f_Tasks As PendingTasks
  Private WithEvents f_Tmp As CPMClientJobProject

My Defines in UnivForm - basically my global variables and such that are used throughout the application. These are created at start up, and they handle all the actual operation of the application. WindowsHookLib is a keyboard hook dll to interface with the Win32 SetWindowsHookEx() API function. This is a third-party DLL, but i have used it with other smaller applications else where and it has never caused a problem. To Be sure i did remove it from my code (a total of about 4 lines - New(), AddHandler, Start(), Stop()) to make sure.

VB.NET:
Sub MainFormLoad(ByVal sender As Object, ByVal e As EventArgs)
  Try
    Me.Width = 1024
    Me.Height = 768
    Me.tm_DefColMenuCmb.SelectedIndex = 6
    MainJobPage.Enabled = False
    stColors = New ColorTableClass()
    ClientList = New ClientListClass()
    Preferences = New UnivPreferences(True)
    ClientForm = New ClientInfoForm(Me)
    FTPFrm = New FTPForm(Me)
    ActiveJobs = New CPMJobListClass()
    KeyHook = New WindowsHookLib.LLKeyboardHook()
    f_Tasks = New PendingTasks()
    f_Tmp = New CPMClientJobProject()
    KeyHook.InstallHook(True)
    ClientList.LoadTargets()
    ClientForm.ClientList = ClientList
    jt_ClientCmb.Items.Clear()
    jt_ClientCmb.Items.AddRange(ClientList.ToArray())
    FSW.Path = Preferences.JobFolder
    AddHandler KeyHook.KeyDown, New WindowsHookLib.LLKeyboardHook.KeyEventHandler(AddressOf KeyHookKeyDown)
    AddHandler f_Tasks.CJPItemAdded, New PendingTasks.CJPItemAddedHandler(AddressOf TaskCJPAdded)
    AddHandler f_Tasks.ProgressChanged, New PendingTasks.ProgressChangedHandler(AddressOf TaskCJPProgress)
    AddHandler f_Tasks.CJPProcessCompleted, New PendingTasks.CJPProcessCompletedHandler(AddressOf CJPProcessCompleted)
    AddHandler f_Tasks.CJPItemRemoved, New PendingTasks.CJPItemRemovedHandler(AddressOf Me.TaskCJPRemove)
    AddHandler f_Tasks.CJPListSorted, New PendingTasks.ListSortedEventHandler(AddressOf Me.TaskListSorted)
    AddHandler ActiveJobs.PropertyChanged, New CPMJobListClass.PropertyChangedHandler(AddressOf PropertyChanged)
    AddHandler ActiveJobs.JobFileTrigger, New CPMJobListClass.JobFileTriggerHandler(AddressOf JobFileTriggered)
    AddHandler ActiveJobs.ProgressChanged, New CPMJobListClass.ProgressChangedHandler(AddressOf ProgressChanged)
    AddHandler FTPFrm.OnFileDownloadEvent, New FTPForm.FileDownloadEventHandler(AddressOf FTPFileDownload)
    azp_CriteriaCmb.Items.Clear()
    azp_CriteriaCmb.DataSource = CriteriaLabels
    azp_CriteriaCmb.ValueMember = "Value"
    azp_CriteriaCmb.DisplayMember = "DupeName"
  catch ex as exception
    MsgBox(Ex.Message)
  try end
End Sub

As you can see in my Main Form's Load() Event handler, is where I create all my objects. Everything that is "My CODE" accessing Office Interop DLLs, Creating Object List Structures, and defining all my object's event handlers, all occurs here. Nicely wrapped, I might add, in a Try/Catch handler. I had even created bunk integer variable that i manually increment at each creation line so that in my MsgBox() call I would do MsgBox(x & ": " & Ex.Message) so that I would know the last successful operation, and subsequently know where to look. In my attempts to run this application on another system, this Try/Catch block NEVER executed. If the exception was explicitly in my code at this time, I should have received the MsgBox error box describing the event. This tells me only 1 thing: The Error is not explicitly in MY code.
Therefor the error exist before the MainForm Load() event is executed. The only code that I can see, based on my knowledge of .NET, is the Constructor, and the application based initialization, and therefore, by logical deductive reasoning, the ERROR is in .NET. I didn't write the constructor or the application initialization code, so I can't trap the error to find out what it is. That is why I have some anger towards my .NET experience.
I have recently put a try/catch around the Me.InitializeComponents() call in the constructor and i will see if that works to a degree, but at the moment, though I recognize where you are coming from, saying I know my app better and should thus know what it requires, I'm saying the error isn't in my code. Or if it is, it is occurring BEFORE my code gets executed, and thus I have no way to debug. I may be wrong. I may have screwed the pooch entirely with some random line of code that I'm not thinking of. And to be honest, i've made some dumb mistakes with code in the past and end up looking rather sheepish in similar circumstances. But right now, with this simple task of taking an application I wrote and use daily, and setting it up to work on a different system, it is failing in a manner that I cannot debug. If there is a method in the application that is "application.run" or something that I can TRAP this error, i'd be getting somewhere, but I don't know .NET well enough to know where to put this exception handler so that I can SEE what the error is. InvalidOperationException is not clear enough to elucidate the glitch for me to repair. As far as i can tell, the .NET libraries on my system are not the same libraries on everyone else's - and thus I am only left with the conclusion that .NET sucks. Because of this problem I have no other recourse to turn to except the realization that I have WASTED some six months learning a language that doesn't work. I know this is not the case, and I know there is a solution. But I can't find it.

So I come here, and say now: Ignore the Office PIAs. Ignore Shell32. What else could cause the application developed in .NET, compiled with Microsoft's VisualBasic Express, to fail before the MainFormLoad() event is even triggered. If we answer this, the problem will no longer exist, of that I am sure. *smile*

other issues from the past: the SplitContainer component has often plagued me with the MinSize limiting property, as I have often done the math of a 500 width and set panel1 to minsize 200 and panel 2 minsize to 150, and the splitterdistances to 200, and yet the system will complain the splitterdistance must be equal or greater than the minsize. well 200 is equal to 200 in my book, but these errors DID occur at compile time, while trying to run the application through the IDE.

I do have a FileSystemWatcher on the form, could something in it be causing a glitch, such as the WatchFolder or other such specifics?

When i try to play with the VisualBasic Express, it wants to add "Handles x.event" to every one of my events, removing the "AddHandler" statements in my *.Designer.vb files. Is this better/worse than using the AddHandler methodology?

Thanks for your help, dude. I mean, i understand people like me can be frustrating and I really do appreciate the help.

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
PS - I just noticed something, and so we do not go too far off the deep end at the moment:
My FileSystemWatcher is initialized in the UnivForm.InitializeComponent() method, so this would occur before the Load event is triggered. Its Path property was set to folder location that might not exist on other systems. Would this cause the heinous InvalidOperationException? I'm thinking it might, but being that its the weekend I can't test this easily.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
it consistently has a Invalid Operation Exception.
So InvalidOperationException - and what more? There usually is loads of more info following that. First what invalid operation it regards in clear text and then the call stack.

Are you able to deploy an empty dummy project? In case client has a bad .Net installation this would verify it.

"try end" is not valid code. MainFormLoad is missing Handles clause and is therefore not called.

*.Designer.vb files are generated by the Designer and you can not edit these. (same with Application.Designer.vb)

You have mentioned several Framework versions, your application only runs under the Framework version it was compiled for.
 
Back
Top