Connecting Tech Pros Worldwide Forums | Help | Site Map

file not found error with C# dll

jason
Guest
 
Posts: n/a
#1: Nov 17 '05
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


Famel Lee
Guest
 
Posts: n/a
#2: Nov 17 '05

re: file not found error with C# dll


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.

"jason" <iaesun@yahoo.com> wrote in message
news:1116253896.220645.255520@g49g2000cwa.googlegr oups.com...[color=blue]
> 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
>[/color]

jason
Guest
 
Posts: n/a
#3: Nov 17 '05

re: file not found error with C# dll


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

Famel Lee
Guest
 
Posts: n/a
#4: Nov 17 '05

re: file not found error with C# dll


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.

"jason" <iaesun@yahoo.com> wrote in message
news:1116261267.784502.140560@z14g2000cwz.googlegr oups.com...[color=blue]
> 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
>[/color]

jason
Guest
 
Posts: n/a
#5: Nov 17 '05

re: file not found error with C# dll


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

Famel Lee
Guest
 
Posts: n/a
#6: Nov 17 '05

re: file not found error with C# dll


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

"jason" <iaesun@yahoo.com> wrote in message
news:1116269676.550343.185740@o13g2000cwo.googlegr oups.com...[color=blue]
> 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
>[/color]

jason
Guest
 
Posts: n/a
#7: Nov 17 '05

re: file not found error with C# dll


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?

Famel Lee
Guest
 
Posts: n/a
#8: Nov 17 '05

re: file not found error with C# dll


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

"jason" <iaesun@yahoo.com> wrote in message
news:1116271835.686808.144310@g49g2000cwa.googlegr oups.com...[color=blue]
> 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?
>[/color]

jason
Guest
 
Posts: n/a
#9: Nov 17 '05

re: file not found error with C# dll


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.

Famel Lee
Guest
 
Posts: n/a
#10: Nov 17 '05

re: file not found error with C# dll


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.

"jason" <iaesun@yahoo.com> wrote in message
news:1116274449.591182.212930@o13g2000cwo.googlegr oups.com...[color=blue]
> 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.
>[/color]

jason
Guest
 
Posts: n/a
#11: Nov 17 '05

re: file not found error with C# dll


no problem, thanks for the help

Closed Thread