Excel get_Range missing when interop assembly is embedded in .NET 4.0 -
I create a assembly referencing a COM interop DLL. If I embed the embed interp type type COM interop types to correct in the properties of reference (VS2010), an error occurs at run-time when there is no definition for "Get_Range in the object" if the COM interop If the type is not embedded then there is no error.
Does anyone know why a particular method should eliminate worksheet.get_range or how it should work around or any other relevant insights? I should be grateful for any help.
In Interop DLL, there is a reference to the worksheet.get_range (object, [object]). There is no mention of get_range under the worksheet using the reflector on my calling assembly.
Interop assembly I am embedding is generated from Excel9.olb. I am not using PIA because the application targets many Excel versions.
I have not removed it myself yet, but I believe that C # 4.0 Under the embedded COM interop types the syntax has changed for a more "C # friendly" syntax.
Therefore, get_reange (object, [object]) method, you can either cancel the optional parameter (
Type.Missing
Instead), or you can avoid calling the fully received accessor, and instead you can refer using the property name. Square bracket:
// Use of C # 3.0: Excel.Range Range = Worksheet.Get_Range ("A1", type missing); // Excluding optional parameters, using C # 4.0: Excel.Range range = worksheet.get_Range ("A1"); // Using C # 4.0, Using Class-Bracket Indexing: Excel.Range range = Worksheet. Category ["A1"];
Whatever I think, however, you should be able to say this as "old way", where the new indicator syntax is actually telling the 'received' and 'set' accuser Behind the scenes, I really do not know why you have trouble. My guess is that you need to look inside the IntelliSense listing under Worksheet.get_Range
instead of Worksheet.Range
. If this does not work for you, then it seems that there may be something wrong with your setup or installation.
For more information on this, see: by Kirill Osenkov.
Hope this would be helpful ...
Mike
Comments
Post a Comment