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

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

Create Interop dll from type library (Tlbimp) without marshalling attributes

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :.NET Framework


I have the idl of com component, I generate type library using midl and use type library to generate interop dll. I want to create interop dll without any marshalling attribute, for example BSTR should be returned as IntPtr, not as string after marshalling. I could not find any attirbute in TlbImp to control the marshalling, how can I achieve this requirement?

View Complete Post

More Related Resource Links

COM Interop Error loading type library/DLL TYPE_E_CANTLOADLIBRARY error in Vista but not XP

I have created a .NET executable that is using a COM assembly that is located on a servers shared drive but am  having problems getting it to work on a number of machines. I have made sure to register the COM assembly using regsvr32 and doing that it works on the computer that I developed it on. From there I brought it over to a Windows XP computer where it didn't work. I received an error message saying "Error loading type library/DLL ... (TYPE_E_CANTLOADLIBRARY)", which was in reference to the COM assembly. After some trouble shooting I found that if I granted the executable FullTrust in the .NET security model the .NET executable was able to load the assembly and everything worked properly. From there I brought the executable to a Windows Vista computer, registered the COM assembly using regsvr32 and granted the .NET executable FullTrust in .NET but it doesn't work. I get the same error saying "Error loading type library/DLL ... (TYPE_E_CANTLOADLIBRARY)". Any idea why the same steps would work in XP but not in Vista? Am I missing something obvious? Any suggestions would be greatly appreciated.

error with "Create new content" type Translation Management Library


I added the Translation Management feature today, using the following command line:

stsadm -o activatefeature -name TransMgmtlib -url http://mysite

everything seemed to work fine, as no error occurred at this stage, and when I go to my top level site settings, click on "Site libraries and lists", then "create new content" I now see "Translation Management" as an option.

I select this type, click Create, complete the first part of the 'wizard' (Name and Description, etc.), then I'm on step 2 and this is where the error occurs. 

  1. The Workflow select box is disabled, and from the articles I've read this should be usable.
  2. More critically, when I complete this form and click Next, I get a server error:

    Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 

I've googled around, and tried updating various items in my web.config and machine.config, but I cannot find the solution. A lot o

.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

To create a custom control and type while creating a column


HI All,

i am creating a column in the list while creating a column i will have an option for choice field on selecting choice i can see dropdown, radiobutton, Checkbox to select and  can enter list of values. and on clicking ok i will get a column with radiobutton. in newform.aspx and also in editform.aspx

so i need to create the similar functionality with my custom radio button, so on create column i need to show my custom choce on selecting this i need to show my custom radiobutton  and  can enter list of values then on selecting it then click ok to create a column, in edit form and new form i need to show a radio buttons with values.

Thanks in advance




how to create gmail type login?



For my project, i have designed a login page like gmail.

According to the  credentials given by the  users the application should send to the corresponding pages asigned to them.

Please give me the answer.

Thanks in advance.

When create a suvery using type Rating Scale, is it possible to create 5 range text?


When create a suvery using type Rating Scale, is it possible to create 5 range text?

Default range text only show 3 fields

What type of backups create a LSN No.?

What type of backups create a LSN No.?"SQLSERVER DBA" "INDIA"

SPD workflow status show "starting" when I create a document from the library !!. and hangs

I have a document library in MOSS 2007. Have created a WF and that starts "autmatically when new item created" In the document library I have created couple of column those are mandatory (required columns) and user has to fill those column while uploading a document as well creating a document from library. WF has ran and completed succefully  when I use "upload" option to load a document.  As you are aware, when we "upload" a document, we will have to fill all "required columns" and the click "check in" command button.  After I do all this, document get loaded and WD ran succesfully. However, the WF is not running when I create a document (.docx) from this library (using "new" button) !!.  I have filled all required field in the document information panel . After save & exit from WORD application, I can see WF status as "starting". But, it never started and completed.  So I did following and found WF worked !! a) After creating document (.docx) using "new" option I found WF status "starting"!. So,  I did "Check-out and Check-in" manually from document library. After doing this,  WF ran and status has been changed as "completed" b) In SPD, I change workflow start option from "Automatic" to "Manually start".&nb

Unable to create columns in document library after applying custom master page to site

Hi, I have applied a custom master page to a site.There is a document library in it. I am unable to add columns in it or change the default view.Nothing happens when I click on OK butoon after making my changes. However the columns are created/default view is changed when I apply the default master page. Guess I am missing some TagPrefix or sharepoint control on master page.I had solved this problem earlier in this way but don't remeber it now. Can anyone help?

Create buttons for "new item" which create a new page of a specific content type

We have a Pages library (wiki) which supports a few content types (and page layout associated). We want to enable users to click a button for example of "new custom enterprise wiki page" - so a new page of content type article will be open in edit mode. Can someone help how to develop? (it has to mimic the behavior that happens when user creates new page from the Ribbon or Site actions and has to choose the content type, it also has to keep the new page in edit mode and not just create it).  

Prompt "The proper type library could not be found in the system registry" when open SQL2008 Express

Hi folks, I just format my notebook and installed the Win7Pro Eng 32-bit version and then install the SQL2008Express. I restarted my notebook as usual after the installation and open the SQL SMS, it prompt the following error "The proper type library could not be found in the system registry", It's a big dialog with certain text saying I do not have permission...etc. Since, I am using administrator account to open the program already but still fail. I have to repaire the SQL SMS too. May I know any other I can check? Any comment is highly appreciated. Thank you very much! Regards, Tony  

Create Content Type in State Machine Workflow

Hi, I created a state machine workflow in share point 2007 with default associated task list. This is working fine. Now I want to add a custom content type to task in which I want to show 3 fields on task form : Title, Description, status And also I want to set some default values in these fields. How can I create and add this custom content type in state machine workflow ? G. Goyal

Using Workflow to create an InfoPath item in a Forms Library

Hi Experts: Here is my situation: I have a MOSS 2007 server with list A (regular sharepoint list) and List B (InfoPath form library with a published form) This is what I am trying to accomplish using SharePoint Designer: List A is just a basic list User changes a column in list A to a specific value A new form needs to be added to the forms library B SharePoint designer Workflow will not create a valid xml file in the List B forms library. It just creates an invalid file based on the .xsn file template. Does anyone have any experience creating a valid xml form in a forms library using SharePoint Designer workflow? I can't migrate to 2010 so that is not an option. Thanks for all your advise.

COM interop for IMessageFilter, Access Violations and interop attributes

I've been trying to implement IMessageFilter in C# and found something that puzzles me. My initial attempt to manually create the interop interface type and use it resulted in lots of access violations. I then found an article online with a declaration of COM's IMessageFilter that I guess maybe they generated using tlbimp and it has all these attributes [   PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] and adding these attributes everywhere means I stop getting Access violations. This gives me a bunch of questions 1) In IMessageFilter interface, there are HRESULTS everywhere but I don't see anything which is [Out Ref], so I don't undrstand why PreserveSig would make any difference here? 2) Is the MethodImplOptions.InternalCall important? Why? What does it really mean? 3) MethodCodeType = Runtime - apparently MethodCodeType is for use only by compiler writers. So why would it matter whether I include it here or not? And in summary, what has probably made the difference to whether I am getting access violations or not? Thanks, Tim

Interop Marshalling of C++ with pointers in the structure

I have a vendor supplied dll that is written in C++. I need to use it in a C# application and am trying to use Interop. I have .h files and example .cpp code from the SDK, but I'm clearly in over my head. There are dozens of functions defined in this API, but if I can just get started on how to do this, I'd appreciate some guidance. My biggest headeache is pointers. Here's examples of the C++ and how far I got with C# (which i'm sure I totally botched) MY.h: part of the included headers typedef struct my_handle *MY_Handle; MY_API_PUBLIC int _cdecl MY_HandleCreate(MY_Handle *my_handle, const char *serial_number, const char *client_id, const char *product_type, const char *product_version); MY_API_PUBLIC int _cdecl MY_HandleDestroy(MY_Handle *my_handle); MY_API_PUBLIC int _cdecl MY_Init(void); MY_API_PUBLIC int _cdecl MY_Shutdown(void); MY.cpp: some example functions. int MY_Init(void); int MY_HandleCreate(MY_Handle *my_handle, const char *serial_number, const char *client_id, const char *product_type, const char *product_version); int MY_HandleDestroy(MY_Handle *my_handle); int MY_Shutdown(void); MY.cs: The class created to house the interop stuff. class MYClass { //MY_Init() [DllImport("ts.dll", SetLastError = true)] public static extern int MY_Init(); //MY_Shutdown() [DllImport("ts.dll", SetLastError

Provisioning did not succeed. Details: Failed to create the 'Reusable Content' library. OriginalEx

Hi there, I am trying to activate the Feature SharePoint Server Publishing Infrastructure in a Team Site, but I am getting the following message: Provisioning did not succeed. Details: Failed to create the 'Reusable Content' library. OriginalException: Column 'ShowInRibbon' does not exist. It may have been deleted by another user. This environment is running SharePoint 2010 Server, as a result of an upgrade of MOSS 2007 by moving the Content Database. The visual upgrade was applied partially in this Site Collection, not for all the Web Sites. Interestingly for new SharePoint 2010 Site Collections the activation works fine! But not for this specific Site Collection. Any clues? Cheers,Marcel Medina - SharePoint Developer Blog: http://sharepoint4developers.spaces.live.com Blog: http://sharepoint4developersnz.spaces.live.com Blog: http://www.canalsharepoint.com.br/marcelmedina

Cannot create unknown type '{clr-namespace:Blog.LongRunningWorkflow.Example.Activities}WaitForReques

Hi, I am facing problem in loading XAML at runtime. Below is the code please help me. public void ProcessRequest(Request request) { // Get the workflow instance id to use Guid instanceId = this.requestToInstanceMapping[request.Id];         // Setup the arguments that are passed to the workflow          IDictionary<string, object> input = new Dictionary<string, object>();              input.Add("Request", request);            using (FileStream fs = new FileStream(@"ProcessRequest.xaml", FileMode.Open))          {             // Load the ProcessRequest workflow           Activity wf = ActivityXamlServices.Load(fs) as Activity;                            // Create the workflow instance specifying the arguments and instance id                      WorkflowApplication wapp = new WorkflowApplication(wf, input);          string persistenceConnectionString = "Data Source=Dev1;Initial Catalog=InstanceStore;User id=sa;password=xxxxxxx;Asynchronous Processing=True";          &nbs
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