Help! Console app can't find custom dll's

Ryboy

Member
Joined
Feb 6, 2008
Messages
7
Programming Experience
10+
Hi -

vb.net noob here. I've started converting quite a few simple VB6 apps that will run as console apps, but cannot get past something (hopefully simple).

First I converted a couple custom VB6 dll's that will be used for common functions. I compiled them and located them in the framework folder for the development machine I am working on. So far, so good.

For my console app, I am able to add a reference to the dll's in the framework folder, and successfully compile the console app. So far, so good.

However, when I run the app in debug mode, I get an error immediately stating
"Could not load file or assembly xxxxCustomDllnamehere,Version=1.0.2957.28645" blah blah blah.

I can get the console app to run in debug ONLY if I copy the dll's to the /bin directory for exe (or add the dll project code in).

I shouldn't have to do this? What am I doing wrong? I have many apps to create/debug and I don't want to have to schlep around all the dll's each time I want to run through debug.

Thanks for any insight.
 
When you add reference to a .Net library it is copied to build output if you don't configure otherwise. Copying to output is default behaviour and the recommended way of using class libraries in .Net. The other option is registering the library in Global Assembly Cache (GAC), normally only the .Net Framework and such common .Net libraries do this.
 
Thanks for the reply -

Not sure if I fully follow you (OK, I know I don't). What exactly is the recommended way of using class libraries in .Net? You might have to spell it out...

I guess the only way I can relate is to how VB6 used com dll's

When you add reference to a .Net library it is copied to build output if you don't configure otherwise. Copying to output is default behaviour and the recommended way of using class libraries in .Net. The other option is registering the library in Global Assembly Cache (GAC), normally only the .Net Framework and such common .Net libraries do this.
 
What exactly is the recommended way of using class libraries in .Net? You might have to spell it out...
Add reference to the library, when built/deployed this library is copied to local output folder of application and used from there.
 
OK, I've done a few things that now seem to have solved the problem.

1) I created a strong name using the VS 2005 utility for this.
2) I associated this strong name file in my project properties/signings page for the dll's
3) I used the gautil.exe to "register" the dll's in the framework.

Now other projects can use the dll's. This was kind of an obscure process. After doing this I'm not sure if there will be any negative ramifications.

Is this solution portable (i.e. can I copy the dll's and exe's to other workstations and have success)???

Thanks again
 
For referenced assemblies that are signed CopyLocal defaults to False. As you know it is still the local assembly from where you added the reference that is used in development, so there isn't really a point to having this GACed on development machine. In runtime one in GAC is used in preference to one in application path if same assembly identity exists both places. For easiest deployment set CopyLocal=True and it will be included in the ClickOnce package. If you want to install to GAC at client you have to use a Setup Project and add it to GAC folder in deployment filesystem, for application of course no need to CopyLocal in this case.
 
Back
Top