Quoting from the Underscores in .NET Names subsection within the Calling .NET from the Wolfram Language section of the NETLink Tutorial:
.NET/Link maps underscores in type, method, property, and field names to "U".
So me must use:
vbextUComponentType`vbextUctUStdModule
The documentation does not mention it, but in the extremely unlikely event that this mangled name conflicts with another symbol, the one which is defined first takes precedence and the other is unavailable.
Self-contained Example
The question uses an example from the Microsoft Office interop library, which readers may not have. We can use the standard library class System._AppDomain
to see the effect:
InstallNET[];
LoadNETType["System._AppDomain"]
UAppDomain`ReferenceEquals[Null, Null]
(* True *)
Just For Fun
A closer simulation of the original problem is hard to come by using just the standard library since underscores are discouraged .NET standard naming conventions. Just for fun, we can dynamically generate our own DLL that is closer to the example in the question:
First, we generate an assembly that has symbol names containing underscores:
Needs["NETLink`"]
InstallNET[];
$myDll = FileNameJoin @ {$TemporaryDirectory, "MyNs.dll"};
NETBlock @ Module[{provider, parameters, result}
, provider = NETNew["Microsoft.CSharp.CSharpCodeProvider"]
; parameters = NETNew["System.CodeDom.Compiler.CompilerParameters"]
; parameters@OutputAssembly = $myDll
; provider@CompileAssemblyFromSource[parameters,
"namespace MyNs {
public class vbext_ComponentType {
public const string vbext_ct_StdModule = \"fake module\";
}
}" // List
]
];
With that ugliness aside, we can now load and access the problematic symbols:
LoadNETAssembly[$myDll];
LoadNETType["MyNs.vbext_ComponentType"];
vbextUComponentType`vbextUctUStdModule
(* "fake module" *)
Clean up:
UninstallNET[];
DeleteFile[$myDll]
Needs["NETLink`"];LoadNETType[ "Microsoft.Vbe.Interop.vbext_ComponentType"] // NETTypeInfo
doesn't work. ShouId I add some code (for example load a Assembly) ? $\endgroup$Microsoft.Vbe.Interop.dll
registered atC:\Windows\assembly\GAC_MSIL\Microsoft.Vbe.Interop
. refering to docs.microsoft.com/en-us/visualstudio/vsto/…. $\endgroup$LoadNETAssembly[]
can use either the name of the file that contains the assembly or the name of the assembly itself (when the assembly is in the GAC, which is the case here), I have found the name of the assembly by trial and error (turns out to be "Microsoft.Vbe.Interop", but note that this name may be totally different from the name of the file). So after having evaluatedLoadNETAssembly["Microsoft.Vbe.Interop"]
, I was able to reproduce OP's problem. $\endgroup$