Re: Question about ComRegisterFunctionAttribute...
Strele Franz <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
The ComRegister/ComUnregister-functions are per type, so you need to take them out of the Helper class and put them inside your SampleClass class. Hth, Franz > -----Ursprüngliche Nachricht----- > Von: Discussion of development on the .NET platform using any managed > language [mailto:[email protected]] Im Auftrag von Gyorgy > Bozoki > Gesendet: Montag, 28. Jänner 2008 06:41 > An: [email protected] > Betreff: Re: [DOTNET-CLR] Question about > ComRegisterFunctionAttribute... > > Steve, > > Thanks for your reply, but it doesn't seem work even if I set Helper to > be > ComVisible - I get no messageboxes at all. (The types in the DLL get > registered, though.) > > Gyorgy Bozoki > > > -----Original Message----- > > From: Discussion of development on the .NET platform using > > any managed language [mailto:[email protected]] > > On Behalf Of Steve Johnson > > Sent: Sunday, January 27, 2008 11:11 > > To: [email protected] > > Subject: Re: [DOTNET-CLR] Question about > > ComRegisterFunctionAttribute... > > > > "Helper" is not ComVisible. > > > > -- > > Steve Johnson > > > > > > On Jan 27, 2008 8:17 PM, Gyorgy Bozoki <[email protected]> wrote: > > > > > Hi all, > > > > > > I seem to have a problem with ComRegisterFunctionAttribute > > attribute. > > > Here is a bit of sample code: > > > > > > // Start of sample -------------------- // -------------------- // > > > Sample.cs // -------------------- using System; using > > > System.Collections.Generic; using System.Text; using > > > System.Runtime.InteropServices; using System.Windows.Forms; > > > > > > namespace SampleLib > > > { > > > public static class Guids > > > { > > > public const string CLSID_TestGuid = > > > "33DE01D3-DC04-4198-AE5D-58B1A36FC122"; > > > } > > > > > > [Guid ( Guids.CLSID_TestGuid ), ProgId ( > > "SampleLib.SampleClass" )] > > > [ClassInterface ( ClassInterfaceType.AutoDual )] > > > [ComVisible ( true )] > > > public class SampleClass > > > { > > > public void SomeFunc () > > > { > > > MessageBox.Show ( "Something" ); > > > } > > > } > > > > > > public static class Helper > > > { > > > [ComRegisterFunctionAttribute] > > > public static void RegServer ( Type oType ) > > > { > > > MessageBox.Show ( "Register" ); > > > } > > > > > > [ComUnregisterFunctionAttribute] > > > public static void UnregServer ( Type oType ) > > > { > > > MessageBox.Show ( "Unregister" ); > > > } > > > } > > > } > > > > > > // -------------------- > > > // AssemblyInfo.cs > > > // -------------------- > > > using System.Reflection; > > > using System.Runtime.CompilerServices; using > > > System.Runtime.InteropServices; using System.Security.Permissions; > > > > > > [assembly: AssemblyTitle ( "SampleLib" )] > > > [assembly: AssemblyDescription ( "" )] > > > [assembly: AssemblyConfiguration ( "" )] > > > [assembly: AssemblyCompany ( "" )] > > > [assembly: AssemblyProduct ( "SampleLib" )] > > > [assembly: AssemblyCopyright ( "Copyright C 2008" )] > > > [assembly: AssemblyTrademark ( "" )] > > > [assembly: AssemblyCulture ( "" )] > > > [assembly: RegistryPermissionAttribute ( > > SecurityAction.RequestMinimum, > > > ViewAndModify = "HKEY_LOCAL_MACHINE" )] > > > > > > [assembly: ComVisible ( false )] > > > [assembly: Guid ( "86077dae-29ae-4905-855b-798aaa7be210" )] > > > [assembly: AssemblyVersion ( "1.0.0.0" )] > > > [assembly: AssemblyFileVersion ( "1.0.0.0" )] // End of sample > > > -------------------- > > > > > > The build output is a single DLL, SampleLib.dll. > > > > > > It seems that the above code builds without any errors but > > when I try > > > to register the resulting DLL using regasm.exe, the > > RegServer and/or > > > UnregServer function is never called. According to the > > documentation, > > > these functions can be public or private (or internal), but > > they must > > > be static and take a single Type parameter to be called during > > > registration for COM. > > > > > > Is there anything I need to do to make this working? I'm using .Net > > > 2.0with > > > SP1 and I have this same behavior on several computers. Any advice > > > would be greatly appreciated. > > > > > > Thanks, > > > Gyorgy Bozoki =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com