F
Fredrik Wahlgren
Hi
The question i'm about to ask is perhaps more of a C# question but since I
for some weird reson don't get access to all microsoft newsgroups, I will ak
here.
I have an xll which I want to convert to C#. It is quite simple and it must
be both a COM add-in and an automation add-in. It should only run under
Excel. All the logic is done in a C++/ATL dll. The add-in must therefore
create an instance of the dll when it's loaded and keep this IDispatch
pointer until it's unloaded. In my xll, the pointer was a global variable.
The functions will simply pass them on to the dll and reurn the result to
Excel, pretty much like the shim dll.
I now understand that C# doesn't allow global variables. My understanding is
that I need to put my globals in a class, and it should never go out of
scope. I guess a sensible place to create an instance of this class is in
OnStartupComplete. I guess I need a constructor that would create an
instance of my dll. When the add-in is unloaded, I want to do the C++
equivalent of Release on the interface. This probably means I have to do so
in the destructor. I need to make the IDispatch pointer available to all
classes.
The other idea that struck me was that maybe I should declare the pointer
within the namespace where all the IDTExtensibility2 functions reside.
Is this right? I'd appreciate any comments you have on this subject.
Best Regards,
Fredrik
The question i'm about to ask is perhaps more of a C# question but since I
for some weird reson don't get access to all microsoft newsgroups, I will ak
here.
I have an xll which I want to convert to C#. It is quite simple and it must
be both a COM add-in and an automation add-in. It should only run under
Excel. All the logic is done in a C++/ATL dll. The add-in must therefore
create an instance of the dll when it's loaded and keep this IDispatch
pointer until it's unloaded. In my xll, the pointer was a global variable.
The functions will simply pass them on to the dll and reurn the result to
Excel, pretty much like the shim dll.
I now understand that C# doesn't allow global variables. My understanding is
that I need to put my globals in a class, and it should never go out of
scope. I guess a sensible place to create an instance of this class is in
OnStartupComplete. I guess I need a constructor that would create an
instance of my dll. When the add-in is unloaded, I want to do the C++
equivalent of Release on the interface. This probably means I have to do so
in the destructor. I need to make the IDispatch pointer available to all
classes.
The other idea that struck me was that maybe I should declare the pointer
within the namespace where all the IDTExtensibility2 functions reside.
Is this right? I'd appreciate any comments you have on this subject.
Best Regards,
Fredrik