Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

how to pass bstr to com+ that made by C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lightdoll - 29 Jan 2008 09:58 GMT
hello everyone.

i have created a com+ made by C#.

The COM+ is singleton.
   [InterfaceType(ComInterfaceType.InterfaceIsDual)]
   [Guid("9b7384f1-7fd3-444f-acd9-0551ae878caf")]
   public interface IOpenInterface
   {
       bool K_SetEventId(string strSourceId, string strEventId);
       int test();
   }

   [JustInTimeActivation]
   [ObjectPooling(Enabled = true, MinPoolSize = 1, MaxPoolSize = 1,
   CreationTimeout = 5000)]
   [Guid("6d1bcaf4-1d35-44c5-b7cb-7431550ee9c0")]
   [ProgId("EasyEda.OpenInterface")]
   [ComVisible(true)]
   public sealed class IOpenComponent : ServicedComponent, IOpenInterface
   {

       public IOpenComponent() { }

       public int test()
       {
           System.Diagnostics.Debugger.Break();
           return 10;
       }
       public bool K_SetEventId(string strSourceId, string strEventId)
       {
           System.Diagnostics.Debugger.Break();
           return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
       }
 }

i called the test function from dll made by c++.

it's ok.

but i called the other function from dll made by c++.

but a error was happened.

    CoInitialize(NULL);
    HRESULT hr = CoCreateInstance(CLSID_IOpenComponent ,
              NULL, CLSCTX_LOCAL_SERVER,
              IID_IOpenInterface ,
reinterpret_cast<void**>(&gIOpenInterface));
    if(FAILED(hr))
    {
        OutputDebugString("The Interface failed");
        return FALSE;
    }
    printf("%d\n", gIOpenInterface->test());==> it's ok.
    _bstr_t bstr = ::SysAllocString(L"TEST");
    gIOpenInterface->K_SetEventId(bstr, bstr);==> The error was happened.

i tried to solve this problem many times..but i can't...

anyone help me solve this problem.

best regards.
Willy Denoyette [MVP] - 29 Jan 2008 11:10 GMT
> hello everyone.
>
[quoted text clipped - 54 lines]
> _bstr_t bstr = ::SysAllocString(L"TEST");
> gIOpenInterface->K_SetEventId(bstr, bstr);==> The error was happened.

This should work, please post the error message.

Willy.

Note: this issue relates to C++, you might get better answers when posting
to the microsoft.public.vc.language group or to the interop
microsoft.public.dotnet.framework.interop NG.
lightdoll - 30 Jan 2008 04:06 GMT
Thank you for your reply.

            return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
==> i think a part of this has some problem.

because i don't anything in test(), but i called another dll from K_SetEventId

but i don't modify the code yet.

        public int test()
       {
            System.Diagnostics.Debugger.Break();
            return 10;
       }
       public bool K_SetEventId(string strSourceId, string strEventId)
        {
            System.Diagnostics.Debugger.Break();
            return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
strEventId);
        }

> hello everyone.
>
[quoted text clipped - 60 lines]
>
> best regards.
Willy Denoyette [MVP] - 30 Jan 2008 09:36 GMT
> Thank you for your reply.
>
>             return CEdaInterface.edaInstance.K_SetEventId(strSourceId,
> strEventId);
> ==> i think a part of this has some problem.

But what's the problem, any error message?
You are connected to a singleton, why are you calling back into
K_SetEventId? What are you trying to achive here?

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.