Hello,
I am implementing a class in C# that wraps an automation server and am
stuck on something basic. Using the following code fragment:
using System;
using System.Runtime. InteropServices ;
namespace ANamespace
{
public class Wrapper
{
private IDispatch* m_Server;
public Wrapper()
{};
}
}
the compiler complains
Wrapper.cs(70): The type or namespace name 'IDispatch' could not be found
(are you missing a using directive or an assembly reference?)
I suspect I am missing something, but I don't know from where to pull the
IDispatch definition in.
Any help is appreciated.
Phil Coveney 4 5407
> I suspect I am missing something, but I don't know from where to pull the IDispatch definition in.
Why do you need it? Why not simply
private object m_Server;
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mattias, Why do you need it? Why not simply private object m_Server;
Fair enough. In fact, that's what I have been doing to make progress on
this project while I am resolving this. And, if this is Microft's intention
for C# developers, I guess that's what I'll do.
But two things trouble me about this.
First, (I think) it implies that I store all standard COM interface
references in object variables. It seems to me unnecessarily hiding
information about the variable's type. One could extend this logic, I
suppose, and note that I could store integer values in object variables,
which I think we can agree would not be good practice.
Second, since I can store references to .NET interfaces, this (I think)
implies I would develop my class distinguishing between standard COM
interfaces, and typelib-imported + non-COM iterfaces. If I change the
provider of a COM interface service from a COM to a non-COM service, does it
mean I change how I store the reference?
OK, I'm not trying to start a deep philosophy discussion. It just seems
strange that Microsoft would thoughtfully prevent the definition of its core
interfaces from being visible to .NET class designers. I am just trying to
understand its rationale.
Thanks for your help,
Phil Coveney
Phil, t seems to me unnecessarily hiding information about the variable's type.
Unless you're going to use any type specific functionality (ie
IDispatch methods) I don't see that as a problem.
OK, I'm not trying to start a deep philosophy discussion. It just seems strange that Microsoft would thoughtfully prevent the definition of its core interfaces from being visible to .NET class designers.
They don't prevent it, you can declare and use IDispatch if you really
have a reason to. If you do, the field declaration becomes
private IDispatch m_Server;
(not IDispatch*).
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Sparago |
last post by:
I am working with the MSHTML editor control. I used
win32com.client.gencache.EnsureModule on the MSHTML type library to
generate the necessary IDispatch support for all the various
interfaces used by MSHTML.
I have just implemented some of the necessary custom COM
interfaces/gateways to allow me to take control of MSHTML's
right-click menu.
One of the callbacks that MSHTML makes (and I've implemented) is
|
by: Roger That |
last post by:
Hi,
I am trying to use the function "CreateStreamOnHGlobal" from python code
(I need to pass an IStream object to MSXML, like I do in C++ code).
I was able to retrieve a pointer on the IStream object in this way:
from ctypes import *
stream = c_int()
|
by: |
last post by:
well, how can i convert these code to VB.NET? thx
CallJScript(const CString strFunc, const CStringArray& paramArray)
{
CComPtr<IHTMLDocument2> m_spDoc;
m_spDoc.Attach( CHtmlView::GetHtmlDocument() );
//Getting IDispatch for Java Script objects
CComPtr<IDispatch> spScript;
m_spDoc->get_Script(&spDisp);
|
by: Dominic Godin |
last post by:
Hi,
I have decleared the IDispatch interface but I'm having trouble using it.
Word.Application MSWord = new Word.ApplicationClass();
IDispatch wb = (IDispatch)MSWord.WordBasic;
int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID;
string rgsNames = {"DisableAutoMacros"};
|
by: Dmitry Medvedev |
last post by:
Hello,
I need to write C# class, that would implement IDispatch interface to be
used in ActiveScript.
I can't use IReflect interface here due to design issues, I need to handle
GetIDsOfNames and Invoke manually.
I've tried the following code:
| |
by: Charles Law |
last post by:
Hi guys
There's nothing much going on in Interop at the moment, so I'll post this
here as well in case someone can give me a quick answer.
The following is an extract from MSDN:
<extract>
*** Setting the Ambient User Mode on the WebBrowser Object ***
|
by: Jim Hubbard |
last post by:
How would I implement the IDispatch interface to handle the following in
VB.Net
<BEGIN>
Controlling Download and Execution
The WebBrowser Control gives you control over what it downloads, displays,
and executes. To gain this control, you need to implement your host's
IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser
Control is instantiated, it will call your IDispatch::Invoke with this ID.
Set pvarResult to a...
|
by: eselk |
last post by:
I've got an out-of-process COM server (EXE) that I want to be able to
control from Visual Basic. I can already control it from a C/C++ app
without any issues. Under VBA in MS Access 2000, which I think is
similar to VB6, I'm able to get things to work, but now under VB 2005
(Visual Studio 2005) I can't get the same to work. Here is what I'm
doing:
1. Because the COM server only registers with the running object
table, but doesn't...
|
by: Huayang Xia |
last post by:
I am trying to use ctypes to call dll functions. One of the functions
requires argument "struct IDispatch* ". I do have a PyIDispatch object
in python. How can I convert this "PyIDispatch object" to "struct
IDispatch* "?
Thanks in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |