Click here to Skip to main content
16,006,594 members
Home / Discussions / C#
   

C#

 
QuestionHow can I export a class of C++ to C#? Pin
ting6684-Oct-04 16:27
ting6684-Oct-04 16:27 
AnswerRe: How can I export a class of C++ to C#? Pin
Paul Lyons4-Oct-04 16:45
Paul Lyons4-Oct-04 16:45 
GeneralRe: How can I export a class of C++ to C#? Pin
Heath Stewart4-Oct-04 16:49
protectorHeath Stewart4-Oct-04 16:49 
AnswerRe: How can I export a class of C++ to C#? Pin
Heath Stewart4-Oct-04 16:50
protectorHeath Stewart4-Oct-04 16:50 
GeneralAssembly paths and assembly versions Pin
Marc Clifton4-Oct-04 15:56
mvaMarc Clifton4-Oct-04 15:56 
GeneralRe: Assembly paths and assembly versions Pin
Heath Stewart4-Oct-04 16:38
protectorHeath Stewart4-Oct-04 16:38 
GeneralRe: Assembly paths and assembly versions Pin
Marc Clifton6-Oct-04 4:20
mvaMarc Clifton6-Oct-04 4:20 
GeneralRe: Assembly paths and assembly versions Pin
Heath Stewart6-Oct-04 5:02
protectorHeath Stewart6-Oct-04 5:02 
Enumerate the sub-keys and grab the default value of each sub-key. Enumerate each directory to load the assemblies:
using System;
using System.IO;
using Microsoft.Win32;
 
class Test
{
  static void Main()
  {
    using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(
      @"Software\Microsoft\.NETFramework\AssemblyFolders"))
    {
      foreach (string key in rk.GetSubKeyNames())
      {
        using (RegistryKey af = rk.OpenSubKey(key))
        {
          string dir = (string)af.GetValue(null);
          if (Directory.Exists(dir))
          {
            Console.WriteLine("Enumerating \"{0}\"...", dir);
            foreach (string file in Directory.GetFiles(dir, "*.dll"))
            {
              Console.WriteLine(file);
            }
            Console.WriteLine();
          }
        }
      }
    }
  }
}
If you want to check the version of the runtime the assembly uses, you could load it and see which version of mscorlib.dll is required. If this application will be running for a while (like Visual Studio), then you should consider creating a new AppDomain to do this since you cannot unload assemblies and don't want to have all those assemblies loaded for no reason.

Instead of loading the assemblies, you could also load the PE/COFF images and determine the information yourself. You could use IL Reader[^] (from Lutz Roeder, creator of .NET Reflector) to inflect what that could be and not load the assembly into an AppDomain at all.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralRe: Assembly paths and assembly versions Pin
Marc Clifton6-Oct-04 5:13
mvaMarc Clifton6-Oct-04 5:13 
GeneralDll calling other dll Pin
RonBou4-Oct-04 15:56
RonBou4-Oct-04 15:56 
GeneralRe: Dll calling other dll Pin
Heath Stewart4-Oct-04 16:43
protectorHeath Stewart4-Oct-04 16:43 
GeneralRe: Dll calling other dll Pin
Alex Korchemniy5-Oct-04 18:21
Alex Korchemniy5-Oct-04 18:21 
GeneralRe: Dll calling other dll Pin
Blubbo7-Oct-04 2:55
Blubbo7-Oct-04 2:55 
Generalcurrent day of week to variable Pin
Pyro Joe4-Oct-04 15:36
Pyro Joe4-Oct-04 15:36 
GeneralRe: current day of week to variable Pin
Marc Clifton4-Oct-04 15:53
mvaMarc Clifton4-Oct-04 15:53 
GeneralRe: current day of week to variable Pin
Pyro Joe4-Oct-04 16:03
Pyro Joe4-Oct-04 16:03 
GeneralRe: current day of week to variable Pin
benjymous4-Oct-04 22:59
benjymous4-Oct-04 22:59 
GeneralAnimated Gif on my splash screen Pin
kornstyle4-Oct-04 12:08
kornstyle4-Oct-04 12:08 
GeneralRe: Animated Gif on my splash screen Pin
Heath Stewart4-Oct-04 14:39
protectorHeath Stewart4-Oct-04 14:39 
GeneralSQL server Timeout Pin
jagan794-Oct-04 11:34
jagan794-Oct-04 11:34 
GeneralRe: SQL server Timeout Pin
Heath Stewart4-Oct-04 14:43
protectorHeath Stewart4-Oct-04 14:43 
GeneralRe: SQL server Timeout Pin
Brian Nottingham4-Oct-04 17:38
Brian Nottingham4-Oct-04 17:38 
GeneralRe: SQL server Timeout Pin
Heath Stewart4-Oct-04 18:49
protectorHeath Stewart4-Oct-04 18:49 
GeneralRe: SQL server Timeout Pin
Brian Nottingham4-Oct-04 18:57
Brian Nottingham4-Oct-04 18:57 
GeneralRe: SQL server Timeout Pin
Heath Stewart4-Oct-04 19:00
protectorHeath Stewart4-Oct-04 19:00 

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.