views:

524

answers:

4

I have made an INF file, its contents are as follows

[version]
Signature="$CHICAGO$"
AdvancedINF=2.0

[Add.Code]
MyControl.dll=MyControl.dll


; Now installing the ActiveX
[MyControl.dll]
file-win32-x86=thiscab
clsid={05B7BC83-FCA1-452d-9D33-193784FEC637}
FileVersion=1,0,0,1
RegisterServer=yes

but the Control is not registered after Internet Explorer has finished installation, and each time I press F5 to refresh the webpage, my browser shows the Installation prompt.?? which means that it is not installed in my machine. And when I run regasm /tlb /codebase MyControl.dll command it starts working fine... I have written my ActiveX control in C# and here are registering function

[ComRegisterFunction()]
     public static void RegisterClass ( string key )
     {
      // Strip off HKEY_CLASSES_ROOT\ from the passed key as I don't need it
      StringBuilder sb = new StringBuilder ( key ) ;

      sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
      // Open the CLSID\{guid} key for write access
      RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);

      // And create the 'Control' key - this allows it to show up in
      // the ActiveX control container
      RegistryKey ctrl = k.CreateSubKey ( "Control" ) ;
      ctrl.Close ( ) ;

      // Next create the CodeBase entry - needed if not string named and GACced.
      RegistryKey inprocServer32 = k.OpenSubKey ( "InprocServer32" , true ) ;
      inprocServer32.SetValue ( "CodeBase" , Assembly.GetExecutingAssembly().CodeBase ) ;
      inprocServer32.Close ( ) ;
       // Finally close the main key
      k.Close ( ) ;
            //MessageBox.Show("Registered");
     }

Please help me out that why RegisterServer=yes is not calling this function, and I have to call it manually using regasm /tlb /codebase MyControl.dll command?

A: 

did u ever find a solution for this problem?

Thilagam
I make a workarround for that... as RegisterServer=yes is not working.. I have made an other executable file in C#, and bundled the final .cab file with my executable file and "RegAsm.exe" and from my executable I am calling RegAsm.exe with specified arrguments.. it works fine for me.. if anyproblem let me know
Ummar
A: 

There's a bit more detail on how to implement Ummar's workaround in the Downloading C# ActiveX Components through CAB File article on CodeProject

(Disclaimer: I haven't tried it - only found the article a week after I resorted to using ATL and C++ :-( ).

tonys
A: 

When the CAB content specified with RegisterServer=yes is registered, it uses regsvr32. Your C# assembly requires regasm, therefore you need an additional mechanism to enforce regasm. The suggested way is with an msi package, which will give the user a way to uninstall your component.

Anderson