Click here to Skip to main content
15,925,723 members
Home / Discussions / C#
   

C#

 
Generaliterating through xml created from a spreadsheet Pin
wend28-Sep-04 12:51
wend28-Sep-04 12:51 
GeneralRe: iterating through xml created from a spreadsheet Pin
Heath Stewart28-Sep-04 13:11
protectorHeath Stewart28-Sep-04 13:11 
QuestionOutlook sync component? Pin
cmkWildsky28-Sep-04 11:53
cmkWildsky28-Sep-04 11:53 
AnswerRe: Outlook sync component? Pin
Heath Stewart28-Sep-04 13:12
protectorHeath Stewart28-Sep-04 13:12 
GeneralC# COM object to TLB generation problem Pin
Werdna28-Sep-04 10:35
Werdna28-Sep-04 10:35 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart28-Sep-04 15:41
protectorHeath Stewart28-Sep-04 15:41 
GeneralRe: C# COM object to TLB generation problem Pin
Werdna28-Sep-04 16:00
Werdna28-Sep-04 16:00 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart28-Sep-04 18:34
protectorHeath Stewart28-Sep-04 18:34 
You're actually supposed to use the PreserveSigAttribute when you do this. Some times the samples are incorrect. Try compiling the following:
using System;
using System.Runtime.InteropServices;
 
[assembly: ComVisible(true)]
[assembly: Guid("519a4822-f224-47fa-bdc7-8037829365dc")]
 
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("f9b77b61-b4f0-4be4-9c53-ded9592e90c6")]
public interface ITest
{
  [DispId(0)]
  int Foo(string value);
}
 
[ClassInterface(ClassInterfaceType.None)]
[Guid("ae5e53c8-54d6-4667-9396-582f5c8611bf")]
public class Test
{
  public int Foo(string value)
  {
    return value.Length;
  }
}
Compile using:
csc.exe /t:library test.cs
Next, register the library and generate a typelib:
regasm.exe /tlb test.dll
Finally, view the typelib:
oleview.exe test.tlb
You'll see the following:
// Generated .IDL file (by the OLE/COM Object Viewer)
// 
// typelib filename: test.tlb
 
[
  uuid(519A4822-F224-47FA-BDC7-8037829365DC),
  version(1.0),
  custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, Test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
 
]
library Test
{
    // TLib :     // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
    importlib("mscorlib.tlb");
    // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");
 
    // Forward declare all types defined in this typelib
    interface ITest;
 
    [
      odl,
      uuid(F9B77B61-B4F0-4BE4-9C53-DED9592E90C6),
      version(1.0),
      dual,
      oleautomation,
      custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, ITest)    
 
    ]
    interface ITest : IDispatch {
        [id(00000000), propget,
          custom(54FC8F55-38DE-4703-9C4E-250351302B1C, 1)]
        HRESULT Foo(
                        [in] BSTR value, 
                        [out, retval] long* pRetVal);
    };
 
    [
      uuid(AE5E53C8-54D6-4667-9396-582F5C8611BF),
      version(1.0),
      custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, Test)
    ]
    coclass Test {
        [default] interface _Object;
    };
};
If you used PreserveSigAttribute, then it would simply be HRESULT Foo(BSTR value).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralRe: C# COM object to TLB generation problem Pin
Werdna29-Sep-04 4:33
Werdna29-Sep-04 4:33 
GeneralRe: C# COM object to TLB generation problem Pin
Heath Stewart29-Sep-04 5:51
protectorHeath Stewart29-Sep-04 5:51 
GeneralRe: C# COM object to TLB generation problem Pin
Werdna29-Sep-04 6:17
Werdna29-Sep-04 6:17 
GeneralToolBar That Doesn't Move Pin
MarkMokris28-Sep-04 10:04
MarkMokris28-Sep-04 10:04 
GeneralRe: ToolBar That Doesn't Move Pin
Brian Nottingham28-Sep-04 10:28
Brian Nottingham28-Sep-04 10:28 
GeneralRe: ToolBar That Doesn't Move Pin
MarkMokris28-Sep-04 10:44
MarkMokris28-Sep-04 10:44 
General"Independent Display" Pin
monkeymonkey00728-Sep-04 7:11
monkeymonkey00728-Sep-04 7:11 
GeneralRe: "Independent Display" Pin
Christian Graus28-Sep-04 11:50
protectorChristian Graus28-Sep-04 11:50 
GeneralA C# / SQL Query Problem Pin
cemlouis28-Sep-04 6:51
cemlouis28-Sep-04 6:51 
GeneralRe: A C# / SQL Query Problem Pin
Christian Graus28-Sep-04 11:51
protectorChristian Graus28-Sep-04 11:51 
GeneralRe: A C# / SQL Query Problem Pin
Colin Angus Mackay28-Sep-04 12:19
Colin Angus Mackay28-Sep-04 12:19 
GeneralRe: A C# / SQL Query Problem Pin
cemlouis28-Sep-04 14:01
cemlouis28-Sep-04 14:01 
GeneralKeep a Form on Top Pin
MarkMokris28-Sep-04 6:22
MarkMokris28-Sep-04 6:22 
GeneralRe: Keep a Form on Top Pin
Nnamdi Onyeyiri28-Sep-04 6:33
Nnamdi Onyeyiri28-Sep-04 6:33 
GeneralRe: Keep a Form on Top Pin
Anonymous28-Sep-04 6:40
Anonymous28-Sep-04 6:40 
Generaluploading to images to remote server Pin
butchzn28-Sep-04 4:12
butchzn28-Sep-04 4:12 
GeneralRe: uploading to images to remote server Pin
Heath Stewart28-Sep-04 5:14
protectorHeath Stewart28-Sep-04 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.