In my program I current have the path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" hard-coded. I need it to dynamically load DLLs for reflection only.   Is there a registry key or environmental value I could use to avoid hard-coding this?
122091
How can I obtain the .NET Framework directory path inside my C# application?  The folder that I refer is "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"
88322
I have a .NET dll which needs to read it's config settings from it's config file. Usually, the config file is placed in the same directory as the DLL. But how do i read the config file if the DLL is GAC'ed, because I can put only the DLLs in the GAC, and not it's config files.
16670
I'd like to to associate a file extension to the current executable in C#. This way when the user clicks on the file afterwards in explorer, it'll run my executable with the given file as the first argument. Ideally it'd also set the icon for the given file extensions to the icon for my executable. Thanks all.
88991
I have an application that we're trying to migrate to 64bit from 32bit.  It's .NET, compiled using the x64 flags.  However, we have a large number of DLLs written in FORTRAN 90 compiled for 32bit.  The functions in the FORTRAN DLLs are fairly simple:  you put data in, you pull data out; no state of any sort.  We also don't spend a lot of time there, a total of maybe 3%, but the calculation logic it performs is invaluable.  Can I somehow call the 32bit DLLs from 64bit code?  MSDN suggests that I can't, period.  I've done some simple hacking and verified this.  Everything throws an invalid entry point exception.  The only possible solution i've found so far is to create COM+ wrappers for all of the 32bit DLL functions and invoke COM from the 64bit process.  This seems like quite a headache.  We can also run the process in WoW emulation, but then the memory ceiling wouldn't be increased, capping at around 1.6gb.  Is there any other way to call the 32bit DLLs from a 64bit CLR process?
121465
I need to unload a DLL that was loaded with System.loadLibrary(..), anyone know if this is possible?
81715
Edit:  Of course my real code doesn't look exactly like this. I tried to write semi-pseudo code to make it more clear of whay I wanted to do.  Looks like it just messed things up instead.  So, what I actually would like to do is this:  Method&lt;Interface1&gt;(); Method&lt;Interface2&gt;(); Method&lt;Interface3&gt;(); ...   Well ... I thought that maybe I could turn it into a loop using reflection. So the question is: How how do I do it. I have very shallow knowledge of reflection. So code examples would be great.  The scenario looks like this:  public void Method&lt;T&gt;() where T : class {} public void AnotherMethod() {     Assembly assembly = Assembly.GetExecutingAssembly();      var interfaces = from i in assembly.GetTypes()     where i.Namespace == "MyNamespace.Interface" // only interfaces stored here     select i;      foreach(var i in interfaces)     {         Method&lt;i&gt;(); // Get compile error here!     }       Original post:  Hi!  I'm trying to loop through all interfaces in a namespace and send them as arguments to a generic method like this:  public void Method&lt;T&gt;() where T : class {} public void AnotherMethod() {     Assembly assembly = Assembly.GetExecutingAssembly();      var interfaces = from i in assembly.GetTypes()     where i.Namespace == "MyNamespace.Interface" // only interfaces stored here     select i;      foreach(var interface in interfaces)     {         Method&lt;interface&gt;(); // Get compile error here!     } }   The error I get is "Type name expected, but local variable name found". If I try  ...     foreach(var interface in interfaces)     {         Method&lt;interface.MakeGenericType()&gt;(); // Still get compile error here!     } }   I get "Cannot apply operator '&lt;' to operands of type 'method group' and 'System.Type'" Any idea on how to get around this problem?
102136
Is there a way to Invoke an overloaded method using reflection in .NET (2.0).  I have an application that dynamically instantiates classes that have been derived from a common base class.  For compatibility purposes, this base class contains 2 methods of the same name, one with parameters, and one without.  I need to call the parameterless method via the Invoke method.  Right now, all I get is an error telling me that I'm trying to call an ambiguous method.  Yes, I could just cast the object as an instance of my base class and call the method I need.  Eventually that will happen, but right now, internal complications will not allow it.  Any help would be great!  Thanks.
112370
I know that the .NET framework looks for referenced DLLs in several locations   Global assembly cache (GAC) Any private paths added to the AppDomain The current directory of the executing assembly   What order are those locations searched? Is the search for a DLL ceased if a match is found or does it continue through all locations (and if so, how are conflicts resolved)?  Also, please confirm or deny those locations and provide any other locations I have failed to mention.
58030
How would I compare 2 strings to determine if they refer to the same path in Win32 using C/C++?  While this will handle a lot of cases it misses some things:  _tcsicmp(szPath1, szPath2) == 0   For example:    forward slashes / backslashes relative / absolute paths.   [Edit] Title changed to match an existing C# question.
89466
Suppose I am running cmd and I open an application by typing for example start document.pdf  I want to get the exact path of the executable that opens .pdf files  Of course I could search the entire system for the executable but I suppose it would be faster this way because the path is already stored somewhere  I don't know if it makes a difference but I am using Windows 7
41947
I want to get a System.Type given only the type name in a string.  For instance, if I have an object:  MyClass abc = new MyClass();   I can then say:  System.Type type = abc.GetType();   But what if all I have is:  string className = "MyClass";
41745
I have code that references a web service, and I'd like the address of that web service to be dynamic (read from a database, config file, etc.) so that it is easily changed.  One major use of this will be to deploy to multiple environments where machine names and IP addresses are different.  The web service signature will be the same across all deployments, just located elsewhere.  Maybe I've just been spoiled by the Visual Studio "Add Web Reference" wizard - seems like this should be something relatively easy, though.
114098
I'm trying to write some C# code that calls a method from an unmanaged DLL.  The prototype for the function in the dll is:  extern "C" __declspec(dllexport) char *foo(void);   In C#, I first used:  [DllImport(_dllLocation)] public static extern string foo();   It seems to work on the surface, but I'm getting memory corruption errors during runtime. I think I'm pointing to memory that happens to be correct, but has already been freed.  I tried using a PInvoke code gen utility called "P/Invoke Interop Assistant".  It gave me the output:  [System.Runtime.InteropServices.DLLImportAttribute(_dllLocation, EntryPoint = "foo")] public static extern System.IntPtr foo();   Is this correct? If so, how do I convert this IntPtr to a string in C#?
47361
I have built my app for different architectures and would like to create a "dynamic symlink" which takes me to the right version based on a variable.   If the machine I am currently logged in to, is x86, then the symlink should take me to that build.  A mocked example of what I want to do:  $ uname -i x86_64  $ ls -ltr  lrwxr-xr-x  1 dogbane gg     4 Feb 16 15:40 mylink -&gt; @sys/ drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 x86_64/ drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 i386/  $ cd mylink  $ pwd -P ~/x86_64   Is this possible?   I know I can use cd $(uname -i), but want something simpler.
74905
Specifically, in VS 2008, I want to connect to a data source that you can have by right-clicking on the automatically-generated App_Data folder (an .mdf "database"). Seems easy, and it is once you know how.
121716
I've got an arbitrary list of .NET assemblies.  I need to programmatically check if each DLL was built for x86 (as opposed to x64 or Any CPU). Is this possible?
5349
I'm using reflection to loop through a Type's properties and set certain types to their default.  Now, I could do a switch on the type and set the default(Type) explicitly, but I'd rather do it in one line.  Is there a programmatic equivalent of default?