com

How to check ErrorCode for REGDB_E_CLASSNOTREG?

旧城冷巷雨未停 提交于 2019-12-06 05:31:45
try { // call to Com Method } catch (COMException e) { if (e.ErrorCode == 0x80040154) // REGDB_E_CLASSNOTREG. { // handle this error. } } I would like to check if com exception is thrown due to REGDB_E_CLASSNOTREG then handle it. I tried with the code above but it gives warning: Comparison to integral constant is useless; the constant is outside the range of type 'int' I believe this error is due to 0x80040154 is not in Int32 range. Can you suggest any possible solution? or Is there any other way to check this? Use the unchecked keyword: catch (COMException ex) { if (ex.ErrorCode == unchecked(

Dynamically load and use COM object in C#

只谈情不闲聊 提交于 2019-12-06 05:27:35
问题 I have a C# project, where I would like to access MS outlook, if it is installed on a client´s machine. The "access outlook" part has been done by referencing the outlook COM object, and going from there. My problem is now the "if it is installed" part. At the moment, my project doesn´t compile on machines without outlook installed, so I assume that I will have to not reference the outlook component, and instead load and use it dynamically, after detecting that outlook is present, but I haven

Converting a fairly simple C# Class library into a COM object?

不羁的心 提交于 2019-12-06 05:13:42
Here's my problem: I have to call a web service with a secure header from a classic ASP page that returns a complex data type. For various reasons concerning a 3rd party tool it has to be classic ASP. We decided that I should create an external dll to do this - which I did (in c#) so it returns a dataset (Something ASP can understand). However now I need to expose that function to the ASP page. Because this is classic ASP I think the only straightforward way to do this is to expose this class library as a COM object. I need to know the down and dirty easiest way to accomplish this task. What

Seemingly random crashes with VB.NET and COM Interop

僤鯓⒐⒋嵵緔 提交于 2019-12-06 05:08:05
I'm thinking of rewriting a brand new VB.NET application in VB 6. The application runs under terminal services and makes heavy use of COM. For some reason, there is random weirdness with the application - Random Access Violation errors (WinDbg exception analysis points into dll's like comdlg32.dll, mscorwks) Random Buffer Overflow errors (same) Random errors in general - for example this line in Form.Load sometimes throws - Me.Icon = Resources.MyIcon I have followed all possible advice concerning resources, garbage collection, disposal patterns, etc... It just doesn't seem to do any good. I'm

How to attach event to dynamic object or COM object

こ雲淡風輕ζ 提交于 2019-12-06 05:03:26
I think this article has the same problem with me. However, there's no workable solution for my case. I'm using Windows Media Player ActiveX in my program. For some reason, I don't want to add a reference of it and convert to AxHost automatically by IDE. I create the instance by Activator and ProgID protected const string WMP_PROG_ID = "WMPlayer.OCX.7"; private dynamic _wmp; protected virtual bool init(){ try{ _wmp = Activator.CreateInstance(Type.GetTypeFromProgID(WMP_PROG_ID)); } catch{ return false; } return true; } I was tried to do this by Reflection , but I found that dynamic is suitable

How does CreateStdDispatch know what method to invoke?

雨燕双飞 提交于 2019-12-06 04:58:25
问题 i'm faced with implementing an IDispatch interface. There are four methods, and fortunately 3 of them are easy: function TIEEventsSink.GetTypeInfoCount(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetTypeInfo(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetIDsOfNames(...): HResult; { Result := E_NOTIMPL; } It's the last method, Invoke that is difficult. Here i am faced with having to actually case the DispID , and call my appropriate method; unmarhsalling

Why can't I create a COM object in a new thread in Python?

瘦欲@ 提交于 2019-12-06 04:56:12
问题 I'm trying to create a COM Object from a dll in a new thread in Python - so I can run a message pump in that thread: from comtypes.client import CreateObject import threading class MessageThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.daemon = True def run(self): print "Thread starting" connection = CreateObject("IDMessaging.IDMMFileConnection") print "connection created" a = CreateObject("IDMessaging.IDMMFileConnection") print "aConnection created" t =

difference between server.createObject and createobject in asp classic

时间秒杀一切 提交于 2019-12-06 04:47:25
问题 according to http://msdn.microsoft.com/en-us/library/ms524620.aspx you should use server.createObject If you are already familiar with VBScript or JScript, note that you do not use the scripting language's function for creating a new object instance (CreateObject in VBScript or New in JScript). You must use the ASP Server.CreateObject method; otherwise, ASP cannot track your use of the object in your scripts. but some other folks think that server.createObject implies an overhead that most

Copying values from excel to body of outlook email vb.net

时光毁灭记忆、已成空白 提交于 2019-12-06 04:46:47
So this is a more refined version of a question I asked earlier. I have been trying to sort this out for quite a while. I found a site that makes sense, but I can't implement it for some reason. I just want to be able to copy information from excel (tables, charts, ranges, etc) into the body of an outlook email. From here: http://pastebin.com/4VWmcrx6 It suggests: Using VB.NET to copy Excel Range (a table) to body of Outlook email Sub CopyFromExcelIntoEMail() Dim Doc As Word.Document Dim wdRn As Word.Range Dim Xl As Excel.Application Dim Ws As Excel.Worksheet Dim xlRn As Excel.Range Set Doc =

Why do COM libraries used from C# 4.0 require such heavy use of dynamic types?

自作多情 提交于 2019-12-06 04:41:56
问题 In the C# 4.0 demos, I'm seeing lots of code that uses the dynamic type. For example, the following code sets the value of an Excel cell: excel.Cells[1, 1].Value = ... However, you can also access the cell in an early bound manner with a cast: ((Range)excel.Cells[1, 1]).Value = ...; Why don't the Excel COM library just describe the Cell type as a Range type in the first place? Similarly, all the arguments to the following method are dynamic: excel.ActiveWorkbook.Charts.Add(...) Why couldn't