file not found error with C# dll

J

jason

i have written a C# class library dll. it compiles fine, and i copy the
resulting output file (mylibrary.dll) from the Visual Studio debug
folder to another folder on the same machine ("c:\libraries")

then i go into the COM+ MMC and add a new COM+ application
("myapplication") and add new components to that application. now this
is the key: i add the components from the file located at
"c:\libraries\mylibrary.dll"

i launch the application that uses this library, and everything works
fine. HOWEVER, the error comes up when i do the following:

1. change the library and recompile it in VS
2. disable and shut down the COM+ application
3. MOVE the dll file from the VS debug folder to "libraries" folder
4. re-enable and start the COM+ application

now all of a sudden the application using the library reports a file
not found error, because the .dll file isn't in the DEBUG folder.
however, i registered the dll with COM+ from the LIBRARIES folder. why
on earth would it go looking for it in the debug folder??

thanks for any help

jason
 
F

Famel Lee

I am not sure about your project settings, you need to check the post build
events whether the registration script is there. By default, Visual Studio
will generate registration script which calls regsvr32 to register the COM
dll in output folder whenever your re-compile your project. The place you
need to look at is in project settings dialog, build events tab.
 
J

jason

that's exactly what it seems like it's doing. it seems like it is
registering the dll when i perform a build, so thank you for this
useful lead.

however, when i go into the project properties, the common properties
folder, build events settings have both the pre-build and post-build
event command line settings blank. it does say "run the post-build
event?" set to "on successful build"

in the configuration properties folder, build settings, the only thing
that seems to reference registration is "register for com interop"
which is set to true, but that doesn't actually register the dll does
it? i thought it just wrapped it for com style calls.

thanks again,

jason
 
F

Famel Lee

It is post-build events, and I am almost pretty much sure that this is the
reason for your problem. COM+ cannot work with managed code directly at
current time, it needs interop to call managed code. You can remove the self
registration script from post build events safely. Normally they are only
useful when you changed the inerface.
 
J

jason

yeah, it seems like it would be the cause. so i suppose my last
question is "how do i remove the post-build event script?"

the only three options listed under "Run the Post-Build Event?" setting
are "Always," "On successful build," and "Only when the build updates
the project output file."

i don't see an option for "Never." so how can i remove the self
registration script? thanks!

jason
 
F

Famel Lee

Is it possible to just remove the command from the Post Build Event Command
Line? You can just remove the command that calls registor.
 
J

jason

that's just it, the Post-Build Event Command line settings are empty.
there are no command lines set. is it possible some other setting is
causing the automatic registration?
 
F

Famel Lee

Do you have anything from the build log of the Visual Studio? It logs all
operations in the build log file.
 
J

jason

not to ask a silly question, but how do i activate/view the build log?
i can't find any reference to the build log in the visual studio help
articles, except for VC++ projects.
 
F

Famel Lee

Sorry, I didn't notice that C# projects do not have build log file. This is
out of my kowledge now. I got similiar problem two years ago which we were
using a seperate proxy/stub dll for the COM+ component and the registration
of the proxy/stub dll causes a lot of problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top