Click here to Skip to main content
16,021,125 members
Home / Discussions / C#
   

C#

 
QuestionIs MS Access transaction-aware? Pin
CillyMe10-Nov-03 23:53
CillyMe10-Nov-03 23:53 
AnswerRe: Is MS Access transaction-aware? Pin
Hesham Amin11-Nov-03 0:41
Hesham Amin11-Nov-03 0:41 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 2:02
CillyMe11-Nov-03 2:02 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 2:50
CillyMe11-Nov-03 2:50 
GeneralRe: Is MS Access transaction-aware? Pin
Hesham Amin11-Nov-03 7:44
Hesham Amin11-Nov-03 7:44 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 16:47
CillyMe11-Nov-03 16:47 
GeneralBuilding Objects with Reflection Pin
Dennis Klein10-Nov-03 22:49
Dennis Klein10-Nov-03 22:49 
GeneralRe: Building Objects with Reflection Pin
Heath Stewart11-Nov-03 3:32
protectorHeath Stewart11-Nov-03 3:32 
It's failing because your not loading the containing assembly correctly. If you read the documentation for Assembly.CreateInstance, it returns null if the type was not found. Since you're dealing with value types - which cannot be null - casting a null reference to a value type will throw an exception.

I think you're missing the point of the global assembly cache (GAC). You don't have to - nor should you - worry about where the assemblies are so long as they are in the GAC or the private path (the "bin" folder, for instance, in ASP.NET). .NET, first of all, does not use the %PATH% env var. If the Type you want to create is contained in an assembly in the GAC or the private path of your application, you simply create the Type and assembly - if not already loaded - is loaded from the GAC automatically (and if a pre-JIT'ed (native) assembly exists, it'll be used instead because it loads and executes faster).

Try this:
// Get the Type - this'll load the assembly automatically.
Type t = Type.GetType("System.Drawing.Size, System.Drawing", false, true);
// The assembly is now loaded - create an instance.
Size s = (Size)t.Assembly.CreateInstance(t.ToString(), ...);
Of course, there's many other ways to do this. The important thing is that you shouldn't worry about the paths to assemblies themselves unless they are your assembly in a non-private path, such as plugins or something. The .NET base class library (BCL) is in the GAC and should not be referenced by a local file path. Besides, the method you're using for finding the local path is extremely slow and inefficient. If nothing else, you should at least cache the directory once you've found it and avoid the large loop every time.

 

-----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: Building Objects with Reflection Pin
Dennis Klein11-Nov-03 22:12
Dennis Klein11-Nov-03 22:12 
GeneralRe: Building Objects with Reflection Pin
Heath Stewart12-Nov-03 2:39
protectorHeath Stewart12-Nov-03 2:39 
GeneralRe: Building Objects with Reflection Pin
Dennis Klein12-Nov-03 3:25
Dennis Klein12-Nov-03 3:25 
Generalcommunicate with service Pin
Member 67650610-Nov-03 22:45
Member 67650610-Nov-03 22:45 
GeneralRe: communicate with service Pin
Arjan Einbu10-Nov-03 23:03
Arjan Einbu10-Nov-03 23:03 
GeneralCOM+ application load balancing Pin
CillyMe10-Nov-03 20:34
CillyMe10-Nov-03 20:34 
GeneralLoading data to string variable Pin
Rostrox10-Nov-03 19:19
Rostrox10-Nov-03 19:19 
GeneralRe: Loading data to string variable Pin
Corinna John10-Nov-03 19:47
Corinna John10-Nov-03 19:47 
GeneralRe: Loading data to string variable Pin
Jeff Varszegi11-Nov-03 4:54
professionalJeff Varszegi11-Nov-03 4:54 
GeneralRe: Loading data to string variable Pin
Jeff Varszegi11-Nov-03 6:04
professionalJeff Varszegi11-Nov-03 6:04 
GeneralControl/Class Existence Pin
Anonymous10-Nov-03 17:47
Anonymous10-Nov-03 17:47 
GeneralRe: Control/Class Existence Pin
Heath Stewart11-Nov-03 3:36
protectorHeath Stewart11-Nov-03 3:36 
GeneralRe: Control/Class Existence Pin
Bhangorix11-Nov-03 23:55
Bhangorix11-Nov-03 23:55 
GeneralRe: Control/Class Existence Pin
Heath Stewart12-Nov-03 2:57
protectorHeath Stewart12-Nov-03 2:57 
GeneralRe: Control/Class Existence Pin
Bhangorix16-Nov-03 19:12
Bhangorix16-Nov-03 19:12 
GeneralConverting an Image to an Icon Pin
Adam Turner10-Nov-03 13:47
Adam Turner10-Nov-03 13:47 
GeneralRe: Converting an Image to an Icon Pin
Corinna John10-Nov-03 19:54
Corinna John10-Nov-03 19:54 

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.