June 3rd, 2013, 02:31 PM
Dll reference imported as interop?
Hello again, once more I'm having an old problem with referencing libraries. From my VS2010 project window, I add a reference to a .dll file, either selecting the file itself or from the COM tab list, and my project runs perfectly. The bin\Release\.exe file also runs ok. Not sure why, but the dll I import is copied as Interop.dllname.dll, even if referenced from the COM tab when added, which I'm assuming is something like the GAC?
The DLL is a 3rd party library and the software that uses it may be installed on the target computers.
The problem is, when I copy the file and dll to another computer that has that software installed, then my app doesn't work. It loads ok, but when I push a button that triggers use of the DLL I get a "The app stopped working" messagebox.
How can I check which library/version/culture/whatever my app is looking for and what it is actually finding? I read the search order is GAC first, app domain second and executable path third, so I'm guessing if a DLL with the same name is already registered but it is another version, it would crash. The problem is I am adding a reference to the same DLL registered in the target machines, so I'm referencing the same DLL version as far as I know... not really sure that's the reason.
I also looked up how to bypass GAC and go straight to local exe directory for searching dlls, but I could not figure out the System.Reflection.Assembly stuff. I found something about having a exefilename.exe.local file in the same directory as the exe file, that would trigger the OS to search for dlls in that path instead of GAC first, but it didn't work for me (in Win7)
It's nuts... the people that have to original app and want to use my support app can't use it...!
Anyway, thanks a lot again for any help!
June 3rd, 2013, 03:32 PM
Re: Dll reference imported as interop?
You say it may be installed on target computers? Understand that if the DLL is a COM dll, then copying it to the target computer will not be sufficient. You'll need to copy the dll (and any dependent dlls) and register it with regsvr32.exe or mark the DLL as a COM DLL in your installer program and let it register it for you.
Originally Posted by Nikel
Btw, the Interop.dllname.dll assembly that gets created for you is simply a wrapper dll to the registered COM interface - it's what is used to connect the C# code to the COM interface. You need to include this assembly in your setup program as well as the registered COM dll (and dependencies).
If you don't include the Interop dll and/or you have not registered the COM dll on the target machine, it won't work.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!