How to cast for GetOcx()

B

Brett

I have this code and VB.NET and need to use it in C#:

Dim cacheInfo As clInetSuiteX5.IclIECacheInfo
cacheInfo = clUploader1.GetOcx()

Reference in VB.NET project:
AxclInetSuiteX5 (AxInterop.clInetSuiteX5)
clInetSuiteX5 (Interop.clInetSuiteX5)

[C#]
public string myMethod()
{
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclUploader)clInetSuiteX5.clUploader.GetOcx();
}

Reference in C# project is clInetSuiteX5 (Interop.clInetSuiteX5). Error in
C# project is:
clInetSuiteX5.clUploader' does not contain a definition for 'GetOcx'

The "using" and "Imports" parts do not include references to this ActiveX
object. Any suggestions on how I can get to the GetOcx() method?

Thanks,
Brett
 
B

Brett

Brett said:
I have this code and VB.NET and need to use it in C#:

Dim cacheInfo As clInetSuiteX5.IclIECacheInfo
cacheInfo = clUploader1.GetOcx()

Reference in VB.NET project:
AxclInetSuiteX5 (AxInterop.clInetSuiteX5)
clInetSuiteX5 (Interop.clInetSuiteX5)

[C#]
public string myMethod()
{
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclUploader)clInetSuiteX5.clUploader.GetOcx();
}

Reference in C# project is clInetSuiteX5 (Interop.clInetSuiteX5). Error
in C# project is:
clInetSuiteX5.clUploader' does not contain a definition for 'GetOcx'

The "using" and "Imports" parts do not include references to this ActiveX
object. Any suggestions on how I can get to the GetOcx() method?

Thanks,
Brett

I needed to add this reference to the C# project AxclInetSuiteX5
(AxInterop.clInetSuiteX5). Then add these lines:

AxclInetSuiteX5.AxclUploader clUploader1 = new
AxclInetSuiteX5.AxclUploader();
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclIECacheInfo)clUploader1.GetOcx();

Brett
 
B

Brett

Brett said:
Brett said:
I have this code and VB.NET and need to use it in C#:

Dim cacheInfo As clInetSuiteX5.IclIECacheInfo
cacheInfo = clUploader1.GetOcx()

Reference in VB.NET project:
AxclInetSuiteX5 (AxInterop.clInetSuiteX5)
clInetSuiteX5 (Interop.clInetSuiteX5)

[C#]
public string myMethod()
{
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclUploader)clInetSuiteX5.clUploader.GetOcx();
}

Reference in C# project is clInetSuiteX5 (Interop.clInetSuiteX5). Error
in C# project is:
clInetSuiteX5.clUploader' does not contain a definition for 'GetOcx'

The "using" and "Imports" parts do not include references to this ActiveX
object. Any suggestions on how I can get to the GetOcx() method?

Thanks,
Brett

I needed to add this reference to the C# project AxclInetSuiteX5
(AxInterop.clInetSuiteX5). Then add these lines:

AxclInetSuiteX5.AxclUploader clUploader1 = new
AxclInetSuiteX5.AxclUploader();
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclIECacheInfo)clUploader1.GetOcx();

Brett

When I run this code, I get an error on the first line:
[myMethod] Could not instantiate ActiveX control
'e47ee4d5-f7db-4f8d-bf0b-112f8e2f17cb' because the current thread is not in
a single-threaded apartment.

What exactly is wrong?

Thanks,
Brett
 
B

Brett

Brett said:
Brett said:
Brett said:
I have this code and VB.NET and need to use it in C#:

Dim cacheInfo As clInetSuiteX5.IclIECacheInfo
cacheInfo = clUploader1.GetOcx()

Reference in VB.NET project:
AxclInetSuiteX5 (AxInterop.clInetSuiteX5)
clInetSuiteX5 (Interop.clInetSuiteX5)

[C#]
public string myMethod()
{
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclUploader)clInetSuiteX5.clUploader.GetOcx();
}

Reference in C# project is clInetSuiteX5 (Interop.clInetSuiteX5). Error
in C# project is:
clInetSuiteX5.clUploader' does not contain a definition for 'GetOcx'

The "using" and "Imports" parts do not include references to this
ActiveX object. Any suggestions on how I can get to the GetOcx() method?

Thanks,
Brett

I needed to add this reference to the C# project AxclInetSuiteX5
(AxInterop.clInetSuiteX5). Then add these lines:

AxclInetSuiteX5.AxclUploader clUploader1 = new
AxclInetSuiteX5.AxclUploader();
clInetSuiteX5.IclIECacheInfo cacheInfo =
(clInetSuiteX5.IclIECacheInfo)clUploader1.GetOcx();

Brett

When I run this code, I get an error on the first line:
[myMethod] Could not instantiate ActiveX control
'e47ee4d5-f7db-4f8d-bf0b-112f8e2f17cb' because the current thread is not
in a single-threaded apartment.

What exactly is wrong?

Thanks,
Brett

I do have this on my main form:
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top