Click here to Skip to main content
15,880,469 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enumerations Pin
Colin Angus Mackay12-Jan-04 5:56
Colin Angus Mackay12-Jan-04 5:56 
GeneralRe: Enumerations Pin
Niels Penneman12-Jan-04 5:58
Niels Penneman12-Jan-04 5:58 
GeneralRe: Enumerations Pin
Heath Stewart12-Jan-04 8:38
protectorHeath Stewart12-Jan-04 8:38 
QuestionUnregister Server Activated Object ? Pin
Stefan Troschuetz12-Jan-04 2:35
Stefan Troschuetz12-Jan-04 2:35 
AnswerRe: Unregister Server Activated Object ? Pin
Heath Stewart12-Jan-04 3:57
protectorHeath Stewart12-Jan-04 3:57 
GeneralRe: Unregister Server Activated Object ? Pin
Stefan Troschuetz12-Jan-04 5:54
Stefan Troschuetz12-Jan-04 5:54 
GeneralCould not load type. Pin
Simon Wren12-Jan-04 1:16
professionalSimon Wren12-Jan-04 1:16 
GeneralRe: Could not load type. Pin
Heath Stewart12-Jan-04 2:38
protectorHeath Stewart12-Jan-04 2:38 
A TypeLoadException can occur for many reasons. Since each Type is a fully-qualified class name (includes an optional namespace) in an assembly that has a version, culture, and public key token, any change to that assembly would cause an invalid type. For instance, if you compiled your app against version 1.0.0.0 of your library and the library version was 1.0.0.1 and you had no binding redirection configured in your .config file, a TypeLoadException will be thrown.

If the assembly in which the Type is contained is not in the current directory, a path configured in the <probing> configuration section of your .config file, or the Global Assembly Cache (GAC) a TypeLoadException will be thrown.

How can you avoid these problems? For one, stop using automatic versioning (when the AssemblyVersionAttribute contains an asterisk). This was, IMO, a bad addition to .NET because versions are VERY important in resolving assemblies, unlike native DLLs. Automatic versioning for them would've been nice (it was possible through macros) but for .NET assemblies it is bad. You have no control over the assembly versions.

Second, use project references. If you have the source to a project and want to reference the resulting assembly in another project, click on the Projects tab of the Add References dialog and add a reference to the project to be configured as a dependency. This keeps track of the outputs and will compile the same build configuration of each project (Debug, Release, etc.). This also makes sure that any changes in the dependent assembly will cause the that to be recompiled when you compile the assembly that has a that dependency. If you use a file reference, this will not happen automatically. If you continue to use automatic versioning, you should definitely use a Project reference so that any changes that cause the version # to be different will recompile the target assembly which will bind against that new version.

Finally, make sure that all dependent assemblies exist on the target machine. The base class library assemblies will already be present if .NET is installed (and obviously it must be). Make sure the correct version of .NET is installed, too. While each framework is both forward- and backward-compatible, they are not 100% compatible between versions. Things change some times so some Types may be different. Also make sure that any third-party libraries that your libraries reference are also installed into the GAC (so you don't have to worry about resolving assemblies).

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Could not load type. Pin
Simon Wren12-Jan-04 2:54
professionalSimon Wren12-Jan-04 2:54 
QuestionButtons? Pin
thomasa12-Jan-04 0:41
thomasa12-Jan-04 0:41 
AnswerRe: Buttons? Pin
Heath Stewart12-Jan-04 3:14
protectorHeath Stewart12-Jan-04 3:14 
GeneralPictureBox - Getting current mouse location Pin
MrEyes12-Jan-04 0:13
MrEyes12-Jan-04 0:13 
GeneralRe: PictureBox - Getting current mouse location Pin
Heath Stewart12-Jan-04 3:08
protectorHeath Stewart12-Jan-04 3:08 
GeneralRe: PictureBox - Getting current mouse location Pin
MrEyes12-Jan-04 3:25
MrEyes12-Jan-04 3:25 
GeneralShould I change C++ to C# Pin
TWS_Dave11-Jan-04 22:27
TWS_Dave11-Jan-04 22:27 
GeneralRe: Should I change C++ to C# Pin
Mazdak11-Jan-04 22:39
Mazdak11-Jan-04 22:39 
GeneralRe: Should I change C++ to C# Pin
Michael P Butler11-Jan-04 23:12
Michael P Butler11-Jan-04 23:12 
GeneralRe: Should I change C++ to C# Pin
Heath Stewart12-Jan-04 2:53
protectorHeath Stewart12-Jan-04 2:53 
GeneralRe: Should I change C++ to C# Pin
Rocky Moore12-Jan-04 10:55
Rocky Moore12-Jan-04 10:55 
GeneralRe: Should I change C++ to C# Pin
TWS_Dave13-Jan-04 23:16
TWS_Dave13-Jan-04 23:16 
GeneralRe: Should I change C++ to C# Pin
Giles14-Jan-04 11:23
Giles14-Jan-04 11:23 
GeneralFolder Browser Dialog Pin
Itanium11-Jan-04 20:46
Itanium11-Jan-04 20:46 
GeneralRe: Folder Browser Dialog Pin
aneye11-Jan-04 21:55
aneye11-Jan-04 21:55 
GeneralRe: Folder Browser Dialog Pin
Heath Stewart12-Jan-04 2:10
protectorHeath Stewart12-Jan-04 2:10 
GeneralPaging - Performance - Scalability Pin
Mohamad Al Husseiny11-Jan-04 20:04
Mohamad Al Husseiny11-Jan-04 20:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.