com

Trace not working in a .NET DLL loaded from VB6 EXE

孤者浪人 提交于 2019-12-01 18:04:49
I have a .NET DLL that writes to the Trace. But it seems that when I call my DLL from a VB6 EXE the trace is not working. I have created an myApp.config file in the EXE folder with the trace configuration, but this does not solve the issue. I've also tried creating the Trace objects in code, but doesn't work: Dim _traceSrc As TraceSource = New TraceSource("myTraceSorce") Dim flListener As FileLogTraceListener = New FileLogTraceListener("myFileLogTraceListener") Dim tSwitch As SourceSwitch = New SourceSwitch("mySwitch") tSwitch.Level = _logLevel If I call my DLL from a .NET EXE it works, even

How do I generate COM interop proxies into C# source code?

ε祈祈猫儿з 提交于 2019-12-01 17:46:35
问题 This questions is a follow up on an answer by Paul Alexander to the question "Should interop assemblies be signed?". Depending on how complex your Interop assemblies are - you can generate the proxy code into a separate .CS/.VB file and compile it directly into your assembly. Then you won't have to worry about strong name issues. How would I go about generating the interop proxy code for a COM library into C# source code? I guess it could be done with tlbimp and then extracting the source

Why exactly does regasm warn me about signing with a strong name?

♀尐吖头ヾ 提交于 2019-12-01 17:46:01
If I want to make a .NET assembly usable as a COM server I have to add a set of attributes and then use regasm to register it as a COM server. If the assembly is not signed with a strong name regasm when run with /codebase key shows a RA0000 warning saying that the assembly could interfere with other assemblies on the same computer and I should sign it with a strong name, but registration succeeds and it even works just fine. AFAIK strong names are intended to prevent so-called DLL hell. But COM was also meant to prevent DLL hell. If I change any interface exposed to COM I must either change

Serialize COM variant to BLOB or IStream

拈花ヽ惹草 提交于 2019-12-01 17:44:48
问题 Is there a standard way to serialize and deserialize a COM VARIANT, e.g. to/from a stream? Haven't found any in MSDN, an I'm a little surprised now. 回答1: You can do this using the the VARIANT_UserMarshal function. General information on this function (and similar ones for other OLE Automation types) is available here: Marshaling OLE Data Types and here: The type_UserMarshal Function 来源: https://stackoverflow.com/questions/22959103/serialize-com-variant-to-blob-or-istream

VS 2012.3 Referencing MS Access COM DLL, could not resolve COM reference error

江枫思渺然 提交于 2019-12-01 17:22:41
I created a new Console project in VS2012.3 (32bit exe) and added a COM Type Library reference to Microsoft Access (I tried both 2003 and 2007). The "Microsoft Access" reference shows up in the Add Reference dialog no problem. However, upon closing that dialog VS displays a yellow triangle overlay on the two newly added references, and I get the following build error: Could not resolve COM reference "4affc9a0-5f99-101b-af4e-00aa003f0f07" version 9.0. Object reference not set to an instance of an object. My colleagues are able to do this with no problem on their computer. So I'm trying to

Late binding run-time error in VB6 when creating an object from a .NET assembly

不羁岁月 提交于 2019-12-01 17:21:42
i have a vb6 project that has a reference to a vb.net com library. the project runs well when i use early binding such as: Dim b as object Set b = new myComLib.testObject when i use late binding such as: Dim b as object Set b = CreateObject("myComLib.testObject") i get the following error: Run-time error '429': ActiveX component can't create object Any ideas? thanks The registry entries for the .NET COM Interop class in this case are:- HKEY_CLASSES_ROOT\myComLib.testObject containing a CLSID value and the CLSID entry itself HKEY_CLASSES_ROOT\CLSID\<<myComLib.testObject\CLSID value>> They are

Late binding run-time error in VB6 when creating an object from a .NET assembly

假装没事ソ 提交于 2019-12-01 16:58:10
问题 i have a vb6 project that has a reference to a vb.net com library. the project runs well when i use early binding such as: Dim b as object Set b = new myComLib.testObject when i use late binding such as: Dim b as object Set b = CreateObject("myComLib.testObject") i get the following error: Run-time error '429': ActiveX component can't create object Any ideas? thanks 回答1: The registry entries for the .NET COM Interop class in this case are:- HKEY_CLASSES_ROOT\myComLib.testObject containing a

VS 2012.3 Referencing MS Access COM DLL, could not resolve COM reference error

巧了我就是萌 提交于 2019-12-01 16:44:58
问题 I created a new Console project in VS2012.3 (32bit exe) and added a COM Type Library reference to Microsoft Access (I tried both 2003 and 2007). The "Microsoft Access" reference shows up in the Add Reference dialog no problem. However, upon closing that dialog VS displays a yellow triangle overlay on the two newly added references, and I get the following build error: Could not resolve COM reference "4affc9a0-5f99-101b-af4e-00aa003f0f07" version 9.0. Object reference not set to an instance of

Python clean way to wrap individual statements in a try except block

点点圈 提交于 2019-12-01 16:04:44
I'm currently doing some Python automation of Excel with com. It's fully functional, and does what I want, but I've discovered something surprising. Sometimes, some of the Excel commands I use will fail with an exception for no apparent reason. Other times, they will work. In the VB equivalent code for what I'm doing, this problem is apparently considered normal, and is plastered over with a On Error Resume Next statement. Python does not have said statement, of course. I can't wrap up the whole set in a try except loop, because it could "fail" halfway through and not complete properly. So,

Can you cast a LPTSTR to a BSTR?

浪子不回头ぞ 提交于 2019-12-01 15:49:03
Is it legal to cast a LPTSTR directly to a BSTR? Based on my understanding of BSTR , casting a LPTSTR to a BSTR directly will leave you with a corrupted length prefix. The example code explicitly states that a string literal cannot be stored to a BSTR. Can anyone confirm for me that a LPTSTR/LPCTSTR cannot be cast directly to a BSTR without corrupting the length prefix? EDIT: My confusion is from seeing this used in a call to a COM object. It turns out that when compiling the COM dll, a .tli file is generated that creates an intermediate method. This method takes type _bstr_t . The _bstr_t can