.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

COM Interop , OleAutomation and the deprecated IDispatchImpl attribute...

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :.NET Framework
Hi all, At my work, we have «deeply connected » COM libraries written in the good old days of VB6. Those components can be indifferently called from other components, ASP pages or VBScripts. We want to progressively migrate those components in C# using COM interoperability. After doing some tests, I came upon some “weird” interop behaviors... I’ve managed to make some rather simple examples of my problems; here it goes…   The Tests For our migration scenario, let’s take 4 classes in 4 distinct VB6 libraries each containing a single class. Here’s the dependency graph of the libraries:   Now the call graph of two very simple tests: In the first test, an ASP/VBScript instantiates a DataClass then passes it on to the method ClassB::RunBC , which in turns instantiates and calls a ClassC::CalledByB passing the reference to the DataClass along. The 2nd test is modeled after the first one: ClassC::RunCD calls ClassD::CalledByC still passing a reference to third party object DataClass .   In other words, the ClassC can be called from either VB6 or ASP/VBScript. After compilation of all the projects, here’s the output of the test script:   Now let’s try to migrate LibraryC in C#... Before starting to write anything in C#, we first need to generate interop assemblies for both LibraryA and LibraryD (which

View Complete Post

More Related Resource Links

COM Interop in C# 4.0

Let's take a bit of a recap of how far we've come. We've chatted about dynamic binding in C# and how that all plays in with the DLR, and about named and optional arguments and how they change the way methods are bound. The only other major piece in C# 4.0 is this notion of COM interop. We chatted about how dynamic really is a gateway to interop with different object models and languages (ie interacting with dynamic languages, dynamic object models, javascript objects, HTML DOM etc), but in C# 4.0, we want to go a bit further and provide you a few more tools to help make your interop life much easier.

I am not able to read xml file with XDocument if its Descendants has Attribute xmlns="http://abc.co


I am not able to read xml file with XDocument if its Descendants has  Attribute like:-

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <row ID="1" xmlns="http://www.opentravela.org/OTA/2003/05">
    <var country_name="Caribbean and Rest of the world" city_name="Kingston" flight_category="Economy Class" via="Atlanta" flight_departure="London Heathrow" airline_logo="Delta" adult_fare="Delta" child_fare="660" infant_fare="561" date1="132" date2="2010-08-15" />


I don't know what to do ?

Looking for some help..

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Excel Interop Save as



I want to Save excel workbook using Excel interop in 97-2003 format. Currently I have Office 2007 installed on my machine.

below is the code I am using.

_book.SaveAs("New.xls", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

The solution is little urgent.


Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

.NET Interop: Automate Acceptance Testing With IronRuby


Acceptance testing verifies that the system under development meets the customer's requirements. Learn the benefits here.

Ben Hall

MSDN Magazine March 2009

.NET Interop: Getting Started With IronRuby And RSpec, Part 1


See how IronRuby lets you employ the straightforward Ruby language to create acceptance tests that interoperate with .NET-compliant code.

Ben Hall

MSDN Magazine February 2009

Visual Studio OBA Tools: Simplify OBA Development With Interop API Extensions


To introduce you to VSTO Power Tools Office interop API extensions, we'll walk through the development of an application that automates Outlook, Excel, and Word.

Andrew Whitechapel, Phillip Hoff, and Vladimir Morozov

MSDN Magazine December 2008

Interop: Connect To Mainframe Apps With BizTalk Adapters and .NET


If you have a significant investment in legacy COBOL applications running on mainframes, you need the BizTalk Adapters for Host Integration Server .

Bashar "Bash" Badawi

MSDN Magazine December 2007

CLR Inside Out: Introduction to COM Interop


The CLR allows seamless interactions between Microsoft .NET applications and COM. But how, exactly? The CLR team knows.

Thottam R. Sriram

MSDN Magazine January 2007

Interop: Get Seamless .NET Exception Logging From COM Clients Without Modifying Your Code


Using .NET objects from ASP can help you gain experience with the .NET Framework before migrating to ASP.NET. Your ASP pages will make use of the new .NET components through COM-callable wrappers (CCW). But how will you handle exceptions? This article fills you in.

Matt Adamson

MSDN Magazine January 2005

.NET Remoting: Create a Custom Marshaling Implementation Using .NET Remoting and COM Interop


The .NET Framework offers several methods for customizing the presentation of native .NET and COM object types. One such technique, custom marshaling, refers to the notion of specializing object type presentations. There are times, like when a legacy COM component needs to implement a new interface or when you need to make calls across process or machine boundaries, when custom marshaling saves the day. Elements of COM Interop permit the customizing of COM types while .NET Remoting offers the developer the ability to tailor native .NET types. This article examines these techniques.

Jim Sievert

MSDN Magazine September 2003

DCOM Interop: Generate Custom Managed C++ Wrappers for Easier COM Interoperation Using DCOMSuds


Now that you're writing managed code, you'll certainly want to use your existing COM components, but you can't simply call them directly. Instead, you have to wrap the COM component in a runtime-callable wrapper that acts as a proxy between the component and your managed code. While the CLR provides wrapper classes for this purpose, there will be times when you'll want custom objects to wrap your COM components. One way to get the low-level access you need to precisely control resource cleanup, pass security information, and get access to CLR features is to write your own wrapper class in managed C++. This article shows you how.

Vishwas Lele

MSDN Magazine August 2003

Security Briefs: Hashing Passwords, The AllowPartiallyTrustedCallers Attribute


Keith Brown describes how yo can hash passwords when you want to store them in your own custom database, and when to use the AllowPartiallyTrustedCallers attribure on your assembly.

Keith Brown

MSDN Magazine August 2003

.NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact with COM-based Applications


Very soon, the development of Microsoft .NET applications will require interaction between those apps and existing COM components on both the client and the server. The .NET Framework has made provisions for this interaction by implementing various wrappers for COM objects to allow exposure of their properties and methods to .NET components. These wrappers will make it easy to make the connection between COM and .NET. After discussing wrappers, this article discusses other ways for .NET components to take part in COM+ transactions. To top off the tutorial on the interoperation of COM and .NET, the article discusses how ActiveX containers can host .NET controls, and how .NET containers can host ActiveX controls.

David S. Platt

MSDN Magazine August 2001

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend