In Visual Studio, how do I write a COM object from scratch? There does not seem to be a new project option for a com object.
You have to go to Other Languages -> Visual C++ -> ATL Project to write a COM object.
Xarzu - It would be helpful to know what you're looking to do. If you're looking to build a component that can take advantage of Windows server features such as transactions, object pooling, security or queuing services, you can get by with a COM+ application (which would be written as a C# library application).
If you're diving deeper and not leveraging Windows enterprise services, you're going to be dealing with Visual C++, as Aamir mentioned.
Just wanted to make sure that the right question is getting answered for you.
Related
I have a DLL generated from Visual Studio 2010, but I need to link it to a 2008 project that needs to remain 2008 for various other reasons. Anyone run into similar trouble or have advice?
VS2010 is .NET 4.0
VS2008 is .NET 3.5
So the answer for your question is NO because if the dll is making use of any of the specific .NET 4 features, it wont get executed in your 3.5 environment. Also it may happen that the assembly mapping is different in both the .NET version and that may become one of the reason for the 4.0 dll not getting executed in 3.5 env.
I am not sure, but you may look at COM Interop features. May be it can help you in achieving what you want. But it would be too messy !!
Dynamic-Link libraries (DLL) are an integrated part of the Windows platform from its very beginning. DLLs allow encapsulation of a piece of functionality in a standalone module with an explicit list of C functions that are available for external users. In 1980’s, when Windows DLLs were introduced to the world, the only viable option to speak to broad development audience was C language. So, naturally, Windows DLLs exposed their functionality as C functions and data. Internally, a DLL may be implemented in any language, but in order to be used from other languages and environments, a DLL interface should fall back to the lowest common denominator – the C language.
http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL
Standardized C style interface, should be ok, though that pertains only to non managed C++.
I am trying to learn Interop from C# and C++/CLI. I am starting with creating a C++/CLI project. Most of the examples I found talks about interop with COM however when I am creating a C++/CLI project in Visual studio 2010, under the project templates for Visual C++ project, I don't see any type for COM. Any ideas? Also can I create just a Visual C++ Class Library project to use for this purpose?
You are mixing it up. There are three distinct ways to interop with native code from a managed program, you don't use them all at the same time:
pinvoke through the [DllImport] attribute. Good for C style native APIs
interop through COM. Very well supported by the CLR as long as it is the Automation subset and you have a type library. Just works out of the box, no work needed. Adding COM to existing native code that isn't COM enabled is not productive unless you already have good COM programming skills (know ATL)
wrapper classes created in the C++/CLI language. When the above options are not enough. Required for interop with native C++ classes.
Learning enough C++/CLI to get the job done requires about 3 weeks, truly learning the language is a multi-month effort. Things to focus on when you just use it for writing wrappers is #pragma managed, the proper use of the hat and the difference between the destructor and the finalizer.
It is possibly worth your time to learn more about it, the syntax heavily resembles the syntax of C++/CX, the language extensions added to the MSVC++ compiler that support writing Metro apps for Windows 8. Knowing C++/CLI is 95% of knowing C++/CX.
Sample quick-start wrapper class in C++/CLI in this answer.
What's the best & fastest way to create an unmanaged Windows service with Visual C++ 2010?
Remark: From the lack of search results for this issue I'm suspecting this is either not recommended or trivial (a regular executable) - but I'm checking this for a colleague which insists not using the CLR.
I haven't tried it in VS2010, but it used to be fairly simple to create a Windows Service using ATL. As far as I remember there was even a project template for doing this.
Here's a CodeGuru article describing how to do it in VC++ 6.0.
Edit: Seems like it's still supported in VS2010 since it's still in the docs: ATL Services
I have an existing wizard template created for VC++ from year back, ported to VS2008. It uses the custom wizard jscript/html templating system and DTE object. I've used this successfully for years, but now I want to create an entry for a standard C# project, I see there's no way to customise the C# project settings - the methods are for VC++ only.
Is there something closely related to this for C# projects (or do I have to learn yet another way of creating a wizard for .net apps?)
I think they call this stuff recipes now. You may want to go in the direction the Smart Client Software Factory goes. It works via the Guidance Automation Toolkit.
I'm sorry I can't provide any further info, have never worked with it. Hope I could help you though.
And it turns out to be "Project Templates" (for non-VC++ projects)
I'd like to get started with the Visual Studio 2010 SDK and creating integration packages. All I would like to do for now is provide a new project type and language service. However, I don't know how I should design it...
The package will provide an editor for a programming language that compiles for x86 or ARM processors. The problem is that there are a few language differences depending on which processor you're developing for. I'd rather not have a separate project type for each architecture, however. Preferably, the programmer chooses the architecture when they create the project and the package automatically loads up the specific parts such as the correct language service, configuration settings, and whatever custom tools and dialogs are associated with that architecture.
How would I go about doing this? I've read about "flavored projects", but I don't really understand how to implement them. Is that what I need?
A couple of points to note to get you headed in the right direction:
The interfaces for a language service to hook into the editor have completely changed for VS 2010. I would recommended asking questions on the VS Editor Forum where all the devs for the core VS editor hang out for the speediest answers since the documentation and samples are still incomplete at this point. (There is a compatibility layer to support "old" language services, but you'd be better off just using the new interfaces since you're starting from scratch.)
A "flavored project" (referred to in the docs as a Project Subtype) is a way to add/remove functionality from an existing project system. For example, there is are project flavors for Web Projects, WPF, Devices, Database, etc.... on top of CSProj and VBProj. In these cases C# and VB are the "base" project systems and WPF, Web, Database are flavors that extend the base C#/VB project systems. Since you have a custom language, you should implement your own base project system. Your best bet for starting from scratch would be to build something based off the MPFProj source library.
I'm working on something very similar -- here is my starting point:
http://blogs.msdn.com/noahric/archive/2010/02/15/markdown-part-4-outlining.aspx
It's a very nice example of how to implement an editor extension.