ActiveQt example - COM App - Class naming - visual-studio

I’m tring to add OLE support to my program. I started by compiling one of the Qt examples:
http://doc.qt.digia.com/stable/activeqt-comapp.html
This example, export 1 class and 2 types:
QAXCLASS(Application)
QAXTYPE(Document)
QAXTYPE(DocumentList)
In order to test it, I import it in Microsft Visual C++ (add class, MFC class from Typelib)
The problem is that, after import, my classes are renamed:
CApplication
CDocument
CDocumentList
So when I call CApplication::Getdocuments() it returns a DocumentList* and this class is unknown!
What am I doing wrong?
EDIT: tested in a VB project, and it works fine! So there must be something wrong when importing the tlb in VC++

Related

How do you import definitions from a C library using mono and Runtime.Interopservices?

I am totally unfamiliar with C-Sharp so this is all new to me but I have a framework I am trying to use with mono.
I can import functions from the framework fine, but there are a lot of for instance type definitions (in the form of C preprocessor directives not that I imagine that should make any difference) and definitions of all the error codes.
Now one thought is to just include the header files in the project, but am I right in thinking there is a way to just import them from the framework directly and how do you go about doing so?
As an aside I am working on Mac OS 10.9.1 using Xamarin Studio so any Visual Studio specific solutions will be ineffective.

COMVisible class in VS 2010 assembly still not visible through com

I created a VS 2010 class library. Marked the assembly for Com Visibility. Signed the assembly with a strong key. Created my class, have my entry point method available.
The library works fine from a test project in C#.
I regasm the class library to gac, via:
c:\windows\microsoft.net\framework\v4.0.30319\regasm testdll.dll /tlb: testdll.tlb /codebase
Include the tlb file as a reference in my VB6 project. I find it through resources 'browse' so its there.
When i try to instantiate the class... its empty. the public method that should be available via the public class doesn't show.
Dim objTest as testdll.testclass
set objTest = new testdll.testclass
objTest.testmethod <--- this 'testmethod' doesn't display in intellisense... nothing does.
In addition i tried calling the 'testdll.testclass' via CreateObject, i get the error "ActiveX component can't create object"
Now i have other projects i've done COM visibility for and i've tried comparing the difference, but i don't see any. I can't understand why it isn't working.
Any clues??? tx very much.
Just use an interface... one you define or to use the [ClassInterface(ClassInterfaceType.AutoDual)]
there are comments online you can find that indicate not to use autodual, but if you control the complete usage of your library, it seems like an 'ok' way to go.
I tried all sorts of ways to simulate / understand why my one project didn't need an interface to be visible by an vb project, without success. i had originally thought perhaps possible that it was because that project implemented an IDisposable Interface (the ONLY interface used in the C# projects that is com visible) but that didn't turn out to be the reason. Anyway I don't want to waste anyone else's time on this. thanks for the responses.
this link provides ample information on the subject:
http://anturcynhyrfus.blogspot.com/2011/03/creating-com-visible-c-component.html

C++/CLI wrapper for C++ native dlls

I have native C++ dlls that I need to use in our group's new C# programs. I wanna create C++/CLI wrappers for native C++ dlls, so as to be able to import and compile them in C#.
What I need to know is how to load the dll file in the wrapper source file at the first place. Exactly the same thing that #using <...> does for MSIL, but for loading native C++ dlls.
And also, how will the objects and namespaces inside the dll become accessible then (synatically)?
EDIT:
I use
class __declspec(dllexport) radar
{
// declarations and definitions
...
};
to export my radar class from my radar.dll, and need to import it in a VC++(CLI) program like this: __declspec(dllimport) public class radar; so as to conduct it's definition into C#, but definitely I can't see radar in C#, because its not defined public in VC++(CLI). Even when I wanna use native dll's objects in VC++ dll's code, like radar pos1(); I get:
error C2512: 'radar' : no appropriate default constructor available
How can do this, having just the radar declaration at hand?
END EDIT.
Thank you!
It is automatic, you don't do this yourself. You specify the native DLL import libraries (.lib) in the linker settings for the C++/CLI project, Additional Dependencies setting. The linker links in a reference to the DLL name into the C++/CLI assembly. As soon as the C# code uses any of the managed types in the C++/CLI assembly, the CLR loads the assembly. Windows notices the native DLL references in the DLL and automatically loads them.
This can only come to a good end if Windows can actually find the native DLLs at runtime. Copy them into the build folder of the EXE project. That's awkward, you can do it with a post-build event or by adding them to the C# project with their Copy to Output Directory property set to true.

how do you execute silverlight class library?

When execute the silverlight class library,debugging(F5) is disable.how do I test whether my class library is right?Silverlight class library is only reusable class and components from other project?
how can share the code between the different class libraries by linking source code files between them in silverlight application??
you need to write a demo or test project to exercise the code in your library. typically, from within the project you want to use your library in, you add a reference to the assembly that contains the classes that you want to use. now, for silverlight, you are only allowed to use libraries/assemblies that are silverlight libraries--you are not allowed to use the "normal" windows class libraries.

How to make Intersystems Caché use the new compiled class instead of the older one?

I'm having trouble with loading and compiling a new version of existing classes. At the time they are loaded, there aren't any references in use to them. Class "Test.Extended" extends class "Test.Base". Class "Extended" calls a ClassMethod on class "Base". The problem is that even after loading and performing a forced compile on both classes, the ClassMethod from "Base" that gets called is not the method on the new compiled class, but the older version of it (confirmed by writing to the console).
To compile both, I'm using the following commands from the terminal (f: means force, c: means compile while loading):
NAMESPACE>w $system.OBJ.Load("C:\Test.Base.cls.xml","fc")
Load started on 01/27/2009 10:10:34
Loading file C:\Test.Base.cls.xml as xml
Imported class: Test.Base
Compiling class Test.Base ..................
Compiling routine Test.Base.1
Load finished successfully.
1
NAMESPACE>w $system.OBJ.Load("C:\Test.Extended.cls.xml","fc")
Load started on 01/27/2009 10:10:34
Loading file C:\Test.Extended.cls.xml as xml
Imported class: Test.Extended
Compiling class Test.Extended ..................
Compiling routine Test.Extended.1
Compiling routine Test.Extended.2
Load finished successfully.
1
We need those two file to be loaded and compiled automatically by the system, but we can't do that, because the system keeps using the older version. Does anybody have an idea on how to force Intersystems Caché to use the latest version of compiled classes?
Thanks,
Luis
Here are a couple of things to try:
Instead of loading/compiling each class separately, load both without compiling, then compile both at once.
Like this:
W $SYSTEM.OBJ.Load("C:\Test.Base.cls.xml")
W $SYSTEM.OBJ.Load("C:\Test.Extended.cls.xml")
W $SYSTEM.OBJ.CompileList("Test.Base.cls,Test.Extended.cls","ckf")
The "k" flag tells the compiler to keep the generated source for the classes (.INT files). That will let you see what Cache actually generated (In Studio: View->View Other Code). Your methods get compiled into tags prefixed with "z", so method ABC becomes tag zABC. There's also a timestamp in the compiled source that can help confirm that it actually did something.
The "b" flag might help too. (Include sub-classes).

Resources