I have created an application which inherit the C++ Dll in .Net application with the help of the Link which used the Concept of Virtual Table.I was trying to find out the possibility for inhering C++ Dll in .Net. Above Link is very helpful for me.
Now, I want to inherit my C# class from JSAPI of Firebreath framework which is the supporting framework of Native C++. I am using the Dumpbin.exe to verify which functions are exported in my .Net application.
Please let me know if any solution.
To the best of my knowledge, there is no way to directly do what you want to do; however, you could possibly create something that extends JSAPI that can then wrap a managed object, though, using the reflection APIs to implement methods like HasMethod, HasProperty, GetProperty, SetProperty, and Invoke. Go look at NPObjectAPI in the firebreath source as kinda an example of what I mean. FireBreath has several such objects that make things that don't normally conform to JSAPI act like JSAPI objects.
Related
Has anyone ever got the idea of creating a Factory class with SharePoint server side API to instantiate a wrapper class around SPWeb?
I mean, for site created with different templates, or same template with different features turned on, I want to define different C# classes, so that i can associate different methods with it, and i can leverage all those C# OO features such as inheritance.
As far as i know, a lot of SharePoint classes are either sealed or have internal constructors.
And if i want to bind a SPWeb with something such as a Managed Metadata Navigation Term or non SharePoint type, it might be better to use a wrapper instead of inherit from SharePoint class.
your question is already quiet old, but I came across your idea (looking to implement something similar) and wanted to let you (and everyone reading this) know that for configuration for like Managed Metadata and setting up and environment there is SPMeta2.
It's an open source, free to use framework which allows you to define and configure your SharePoint.
Regarding your other goals, have you implemented something like that, could you be more specific?
first time on SO though I've used the site a lot, I will get straight to the point.
My actual end goal is to create an object which inherits from the IDispatch interface in C# which can be used in Canvases inside of Oracle Forms Builder (Oracle Developer Suite 10g (10.1.2.0.2))
Does anyone have any resources where I can learn how to do this or where any examples of this are shown?
In order to achieve my goal thus far I went to this site : http://www.codeproject.com/Articles/24089/Create-ActiveX-in-NET-Step-by-Step
Here I got some code which allowed me to create and test an activeX object. I believe that all objects utilized by the COM structure. I then registered this using regasm and then I tried to call it. I was able to call it successful in IE.
I was about to recreate this active X object after some time; however, whenever I attempt to import it to Oracle forms I got an error like:
To me the error seems very clear, I obviously did not implement some method that oracle forms needs me to implement. What are the methods I need to implement and how should it be implemented.
Sorry for the long question, any help regarding this will be appreciated.
I suggest you start by reading this description in MSDN of the interfaces which ActiveX controls may expose.
You will need to implement at least the minimum functionality (i.e. minimal set of interfaces) to keep the Oracle Forms Builder happy. Just implementing IDispatch is not sufficient.
I'm learning C# and coming from a Java world, I was a little confused to see that C# doesn't have a "package private". Most comments I've seen regarding this amount to "You cannot do it; the language wasn't designed this way". I also saw some workarounds that involve internal and partial along with comments that said these workarounds go against the language's design.
Why was C# designed this way? Also, how would I do something like the following: I have a Product class and a ProductInstance class. The only way I want a ProductInstance to be created is via a factory method in the Product class. In Java, I would put ProductInstance in the same package as Product, but make its constructor package private so that only Product would have access to it. This way, anyone who wants to create a ProductInstance can only do so via the factory method in the Product class. How would I accomplish the same thing in C#?
internal is what you are after. It means the member is accessible by any class in the same assembly. There is nothing wrong with using it for this purpose (Product & ProductInstance), and is one of the things for which it was designed. C# chose not to make namespaces significant -- they are used for organization, not to determine what types can see one another, as in java with package private.
partial is nothing at all like internal or package private. It is simply a way to split the implementation of a class into multiple files, with some extensibility options thrown in for good measure.
Packages don't really exist in the same way as they do in Java. Namespaces are used to organize code and prevent naming clashes, but not for access control. Projects/assemblies can be used for access control, but you can't have nested projects/assemblies like you can with packages.
Use internal to hide one project's members from another.
I am new to COM and need to add a Server COM object to my c# application so I can call its methods and implement events. The documentation I have says this requires a COM-aware language such as Visual C++. My app is written in C# so I'm not sure how this is going to work. Any direction would be appreciated.
I am writing an app that communicates with a serial hypercom terminal. The device came with a DLL (the com server interface) that I will need to figure out how to use in my c# application.
I added a reference to the DLL to my project, which shows up as a type library. In object explorer I get interfaces, and some classes etc.
Thanks,
Matt
You can add the COM object as a reference. .NET will create an interop assembly to work with the COM object, just like it was a .NET type.
CComObjectRoot can be used as a base class for all COM objects implemented with ATL. As such you don't have to worry to implement something similar in C#, the required methods (AddRef, Release, QueryInterface) will be generated by tlbexp for classes that are tagged with ClassInterface.
STDMETHODIMP is a define which serves to declare the most common methods that can be called from COM (#define STDMETHODIMP HRESULT STDMETHODCALLTYPE). Again if your class is tagged with ClassInterface you will not have to worry about.
Such construction is required in C++ when your class implements several interfaces. I think this is not required if you tell C# compiler that your C# object implement IDispatch, IFPESOlementationEvents. The appropriate code will be written automatically by the compiler.
Probably everything will not make much sense if you are new to COM and C#, I'll suggest to take a look at the various introduction that you may find on the web, like this.
Greetings all,
I’m working on a C# program that requires being able to get the index of the hot item in Windows 7 Explorer’s new ItemsView control. Fortunately, Microsoft has provided a way to do this through UI Automation, by querying custom properties of the control.
Unfortunately, the System.Windows.Automation namespace inexplicably does not seem to provide a way to query custom properties! This leaves me with the undesirable position of having to completely ditch the C# Automation namespace and use only the unmanaged COM version. One way to do it would be to put all the Automation code in a separate C++/CLI module and call it from my C# application. However, I would like to avoid this option if possible, as it adds more files to my project, and I’d have to worry about 32/64-bit problems and such.
The other option is to make use of the ComImport attribute to declare the relevant interfaces and do everything through COM-interop. This is what I would like to do. However, the relevant interfaces, such as IUIAutomation and IUIAutomationElement, are FREAKING HUGE. They have hundreds of methods in total, and reference tons and tons of interfaces (which I assume I would have to also declare), almost all of which I will never ever use. I don’t think the UI Automation interfaces are declared in any Type Library either, so I can’t use TLBIMP.
Is there any way I can avoid having to manually translate a bajillion method signatures into C# and instead only declare the ten or so methods I actually need? I see that C# 4.0 added a new “dynamic” type that is supposed to ease COM interop; is that at all relevant to my problem?
Thanks
The most important thing (from the perspective of calling a COM method from C#) is that the methods appear in the interface in the right order. If you're not using a method, you can just declare it as void and nothing bad will happen (unless you actually call it!). This saves you from having to work out the correct signatures and define all the other types, etc. For example,
[ComImport, Guid("30cbe57d-d9d0-452a-ab13-7ac5ac4825ee"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IUIAutomation
{
void CompareElements();
void CompareRuntimeIds();
void GetRootElement();
// 50 or so other methods...
// ... define only the signatures for the ones you actually need
}
The methods should be defined in exactly the same order they appear in UIAutomationClient.h (in the Windows SDK).