com

in .NET, How do I set STAThread when I'm running a form in an additional thread?

与世无争的帅哥 提交于 2019-12-20 06:30:05
问题 I'm running a form in a second thread. If I do Ctrl-C to copy text on the clipboard, I get an Exception, "Current thread must be set to a single thread apartment (STA) before OLE calls can be made. (Using the clipboard involves OLE apparently). Putting the [STAThread] with my thread proc, which is the entry point of my second thread does NOT work. What will work? [STAThread] private void MyFormThreadproc(object o) { form = new MyForm(); Application.Run(form); } 回答1: When you create the thread

MyGroups not implemented in Communicator.UIAutomation

为君一笑 提交于 2019-12-20 06:09:58
问题 I'm working on a out of browser Silverlight app that provides some MS Office Communicator 2007 controls. I'm using the Automation SDK. The docs that were installed with the SDK state that there's a MyGroups property in the IMessenger2 interface, which will return the groups that a user has defined, but when I try to use it, I get a NotImplementedException . Here's the code that I'm using: dynamic communicator = AutomationFactory.CreateObject("Communicator.UIAutomation"); communicator

Getting IP Address using UPnP InvokeAction not returning anything, help?

流过昼夜 提交于 2019-12-20 05:50:46
问题 Basically, when i use vb.net or c#.net to do this, it works perfectly, but when i use vb6, it doesn't work, in my for loop where the relevant service in the relevant device is captured, here is the code that returns no result... ' serv is properly declared and instantiated by the for loop. Dim xins(0) Dim xouts(0) MsgBox ("Starting..." & serv.ServiceTypeIdentifier & vbCrLf & serv.id & vbCrLf & serv.LastTransportStatus) ' all this shows correctly. serv.InvokeAction "GetExternalIPAddress", xins

How to use tlb file in C?

混江龙づ霸主 提交于 2019-12-20 05:44:11
问题 tlb file(using regasm) is made from a dll(using c# code), and i can use this in c++ using #import. and everything is working fine. Is there a way, i can use this in C language? I just found that #import is c++ specific. So, can someone please tell me how can i use in my C program? my main intention is to use COM DLL developed in C# in my C program. Thanks & Rgds, ~calvin 回答1: COM programming in C is very painful, but not impossible. The buck stops here though. The point of a type library is

Check if a file is a valid SQLite database

一曲冷凌霜 提交于 2019-12-20 05:42:19
问题 I need to check whether a file (with unknown extension) is a valid SQLite database. My function works fine, but when it fails, the file is still locked after exiting the function: Public Function IsSqliteDB(ByVal uPath As String) As Boolean 'Workaround for my problem: Make a copy and work on this because this function is going to lock the file unfortunately Dim sNewPath As String sNewPath = Settings.Locations.Folder_LocalAppData_Temp & "\temp_" & Replace(Now.ToString, ":", "_") & ".db" modIO

Loading and Passing JScript Arrays from/to C# (not C) COM Component

*爱你&永不变心* 提交于 2019-12-20 05:21:26
问题 I have looked at tutorials on jscript arrays, but not seeing it yet. I saw something similar asked but involving Win32 code not .NET. Wondering, how do I pass arrays back and forth between JScript and a C# COM component? For example, I have two properties defined in my C# COM that returns string and integer arrays as: string[] HeaderLines { get; set; } int[] ImagePixels { get; set; } In my test.js file: ... var T = new ActiveXObject("Imager.Reader"); ... var headerLines = T.HeaderLines;

Loading and Passing JScript Arrays from/to C# (not C) COM Component

你说的曾经没有我的故事 提交于 2019-12-20 05:21:14
问题 I have looked at tutorials on jscript arrays, but not seeing it yet. I saw something similar asked but involving Win32 code not .NET. Wondering, how do I pass arrays back and forth between JScript and a C# COM component? For example, I have two properties defined in my C# COM that returns string and integer arrays as: string[] HeaderLines { get; set; } int[] ImagePixels { get; set; } In my test.js file: ... var T = new ActiveXObject("Imager.Reader"); ... var headerLines = T.HeaderLines;

How do I get an error reason from InstallProductKey (SoftwareLicensingService) in PowerShell?

こ雲淡風輕ζ 提交于 2019-12-20 04:41:13
问题 I'm using some PowerShell functions to configure Windows product keys and activation. I get an instance of the SoftwareLicensingService and call InstallProductKey, like this. The trap block with super formatting is extra to help debugging. trap [Exception] { "==================================================" "Trapped: $($Error[0])" "==================================================" "Exception: $($_.Exception)" "--------------------------------------------------" "" break } $service = Get

How do I get an error reason from InstallProductKey (SoftwareLicensingService) in PowerShell?

我是研究僧i 提交于 2019-12-20 04:41:08
问题 I'm using some PowerShell functions to configure Windows product keys and activation. I get an instance of the SoftwareLicensingService and call InstallProductKey, like this. The trap block with super formatting is extra to help debugging. trap [Exception] { "==================================================" "Trapped: $($Error[0])" "==================================================" "Exception: $($_.Exception)" "--------------------------------------------------" "" break } $service = Get

Class not registered

蓝咒 提交于 2019-12-20 04:38:32
问题 I'm working through "Developer's Workshop to COM and ATL 3.0" by Andrew W. Troelsen. I'm trying to implement the lab in Chapter 3. It shows you how to build a COM client to connect to an inprocess COM server that was developed in an earlier lab. When I run the client, I receive the error "Class not registered" when calling 'CoGetClassObject'. Here is a snippet of code: // Get the class factory pointer of CoCar. hr = CoGetClassObject(CLSID_CoCar, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory,