E9: VB-> C# issue

Not sure if this is what you're after, but if you just want to instantiate
a new object in C# the proper syntax should look like this:

ObjectType myNewObject = new ObjectType(<any parameters the constructor
takes>);

Example, creating a new business object:
SalesOrder _mySalesOrder = new
SalesOrder(((Session)oTrans.Session).ConnectionPool);

*John Driggers*
**
*Chief Data Wrangler*
*
*
*I have an Epicor blog <http://usdoingstuff.com/>. How useful is that?*
*
*:: 904.404.9233
:: waffqle@...
:: http://www.usdoingstuff.com <http://www.usdoingstuff.com/>

*

*



On Mon, Oct 1, 2012 at 11:20 AM, Dan Godfrey <dgodfrey@...> wrote:

> **
>
>
> I was reading up on how to instanciate objects and somewhere I read that I
> should be able to use the NEW keyword since I have brought in the assembly
> and the using statement. I did and it seems to be working correctly. It
> doesn't seem to need a createObject. If anyone has some insight on this I
> would love to learn more on the difference from the CreateObject, New(),
> and other ways to instantiate objects.
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of jckinneman
> Sent: Saturday, September 29, 2012 8:28 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: E9: VB-> C# issue
>
> Not sure I see enough of the code you are using to offer an alternate way
> but you can call Visual Basic items from C#.
>
> using ...visualbasic.. // don't have the exact using statement on hand,
> might need to include the dll too.
>
> VisualBasic.Interaction.CreateObject
>
> Jim Kinneman
> Encompass Solutions, Inc
>
> --- In vantage@yahoogroups.com, "dgodfrey_amc" <dgodfrey@...> wrote:
> >
> > What is the equivalent code for CreateObject in C#? I tried to search
> and found something. I am not sure if I am doing it right or it is the
> wrong thing to use. Here is my code:
> >
> > System.Type t =
> > System.Type.GetTypeFromProgID("EpicorXMLGenerator.EpicorXMLGenerator")
> > ;
> >
> > //ProdMan =
> > (EpicorXMLGenerator.EpicorXMLGenerator)System.Activator.CreateInstance
> > (t, true); ProdMan =
> > (EpicorXMLGenerator.EpicorXMLGenerator)System.Runtime.InteropServices.
> > Marshal.GetActiveObject("EpicorXMLGenerator.EpicorXMLGenerator");
> >
> > //ProdMan = CreateObject("EpicorXMLGenerator.EpicorXMLGenerator");
> >
> >
> > This code generates this error:
> >
> > System.Runtime.InteropServices.COMException was caught
> > Message=Operation unavailable (Exception from HRESULT: 0x800401E3
> (MK_E_UNAVAILABLE))
> > Source=mscorlib
> > ErrorCode=-2147221021
> > StackTrace:
> > at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid,
> IntPtr reserved, Object& ppunk)
> > at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
> > at Script.PartForm_Load(Object sender, EventArgs args) in c:\Documents
> and Settings\All Users\Application
> Data\Epicor\ep9-app-9401\9.05.700C\AMC\CustomDLLs\App.PartEntry.PartForm.EP.AMC.Customization.PartEntryBOMForm.CustomCode.1.cs:line
> 3080
> > InnerException:
> >
>
> ------------------------------------
>
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
> already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder and
> Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]
What is the equivalent code for CreateObject in C#? I tried to search and found something. I am not sure if I am doing it right or it is the wrong thing to use. Here is my code:

System.Type t = System.Type.GetTypeFromProgID("EpicorXMLGenerator.EpicorXMLGenerator");

//ProdMan = (EpicorXMLGenerator.EpicorXMLGenerator)System.Activator.CreateInstance(t, true);
ProdMan = (EpicorXMLGenerator.EpicorXMLGenerator)System.Runtime.InteropServices.Marshal.GetActiveObject("EpicorXMLGenerator.EpicorXMLGenerator");

//ProdMan = CreateObject("EpicorXMLGenerator.EpicorXMLGenerator");


This code generates this error:

System.Runtime.InteropServices.COMException was caught
Message=Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
Source=mscorlib
ErrorCode=-2147221021
StackTrace:
at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
at Script.PartForm_Load(Object sender, EventArgs args) in c:\Documents and Settings\All Users\Application Data\Epicor\ep9-app-9401\9.05.700C\AMC\CustomDLLs\App.PartEntry.PartForm.EP.AMC.Customization.PartEntryBOMForm.CustomCode.1.cs:line 3080
InnerException:
Not sure I see enough of the code you are using to offer an alternate way but you can call Visual Basic items from C#.

using ...visualbasic.. // don't have the exact using statement on hand, might need to include the dll too.

VisualBasic.Interaction.CreateObject

Jim Kinneman
Encompass Solutions, Inc

--- In vantage@yahoogroups.com, "dgodfrey_amc" <dgodfrey@...> wrote:
>
> What is the equivalent code for CreateObject in C#? I tried to search and found something. I am not sure if I am doing it right or it is the wrong thing to use. Here is my code:
>
> System.Type t = System.Type.GetTypeFromProgID("EpicorXMLGenerator.EpicorXMLGenerator");
>
> //ProdMan = (EpicorXMLGenerator.EpicorXMLGenerator)System.Activator.CreateInstance(t, true);
> ProdMan = (EpicorXMLGenerator.EpicorXMLGenerator)System.Runtime.InteropServices.Marshal.GetActiveObject("EpicorXMLGenerator.EpicorXMLGenerator");
>
> //ProdMan = CreateObject("EpicorXMLGenerator.EpicorXMLGenerator");
>
>
> This code generates this error:
>
> System.Runtime.InteropServices.COMException was caught
> Message=Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
> Source=mscorlib
> ErrorCode=-2147221021
> StackTrace:
> at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
> at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
> at Script.PartForm_Load(Object sender, EventArgs args) in c:\Documents and Settings\All Users\Application Data\Epicor\ep9-app-9401\9.05.700C\AMC\CustomDLLs\App.PartEntry.PartForm.EP.AMC.Customization.PartEntryBOMForm.CustomCode.1.cs:line 3080
> InnerException:
>
I was reading up on how to instanciate objects and somewhere I read that I should be able to use the NEW keyword since I have brought in the assembly and the using statement. I did and it seems to be working correctly. It doesn't seem to need a createObject. If anyone has some insight on this I would love to learn more on the difference from the CreateObject, New(), and other ways to instantiate objects.

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of jckinneman
Sent: Saturday, September 29, 2012 8:28 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: E9: VB-> C# issue

Not sure I see enough of the code you are using to offer an alternate way but you can call Visual Basic items from C#.

using ...visualbasic.. // don't have the exact using statement on hand, might need to include the dll too.

VisualBasic.Interaction.CreateObject

Jim Kinneman
Encompass Solutions, Inc

--- In vantage@yahoogroups.com, "dgodfrey_amc" <dgodfrey@...> wrote:
>
> What is the equivalent code for CreateObject in C#? I tried to search and found something. I am not sure if I am doing it right or it is the wrong thing to use. Here is my code:
>
> System.Type t =
> System.Type.GetTypeFromProgID("EpicorXMLGenerator.EpicorXMLGenerator")
> ;
>
> //ProdMan =
> (EpicorXMLGenerator.EpicorXMLGenerator)System.Activator.CreateInstance
> (t, true); ProdMan =
> (EpicorXMLGenerator.EpicorXMLGenerator)System.Runtime.InteropServices.
> Marshal.GetActiveObject("EpicorXMLGenerator.EpicorXMLGenerator");
>
> //ProdMan = CreateObject("EpicorXMLGenerator.EpicorXMLGenerator");
>
>
> This code generates this error:
>
> System.Runtime.InteropServices.COMException was caught
> Message=Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
> Source=mscorlib
> ErrorCode=-2147221021
> StackTrace:
> at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
> at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
> at Script.PartForm_Load(Object sender, EventArgs args) in c:\Documents and Settings\All Users\Application Data\Epicor\ep9-app-9401\9.05.700C\AMC\CustomDLLs\App.PartEntry.PartForm.EP.AMC.Customization.PartEntryBOMForm.CustomCode.1.cs:line 3080
> InnerException:
>




------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links