vb to c# conversion

A

Ankit Aneja

i am making client for com dll

in vb i write like this
Dim WithEvents p As CLAMXLib.ClamEngine
Private Sub Form_Load()
Set p = New ClamEngine
p.Database.Path = "E:\projects backup\ankitclam backup\Clamtest\database\"
End Sub

in vc++
IClamEngine *m_spIClamEngine;
::OnInitDialog()
{
m_spIClamEngine.CreateInstance(__uuidof(ClamEngine));
m_spIClamEngine->Database->Path="E:\\projects backup\\ankitclam
backup\\Clamtest\\database\\";
}

in c# not able to write first line in form_load
CLAMXLib.ClamEngine p;
private void Form1_Load(object sender, System.EventArgs e)
{
//first line missing i try p=new CLAMXLib.ClamEngine(); but doesn't show
ClamEngine after CLAMXLib. this time
p.Database.Path="E:\\projects backup\\ankitclam
backup\\Clamtest\\database\\";
}
 
K

Kevin Yu [MSFT]

Hi Ankit,

In C#, when doing Interop, the IDE will create a wrapper for the COM
automatically. When calling new, you can try to use
CLAMXLib.ClamEngineClass(); instead. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
A

Ankit Aneja

ok i write like this
private void Form1_Load(object sender, System.EventArgs e)

{

p=new ClamEngineClass();

p.Database.Path="E:\\projects backup\\ankitclam
backup\\Clamtest\\database\\";


}



but further also in vb

Private Sub cmdExeFileScan_Click()
p.Settings.ScanSupport = Scan_Standard
p.ScanFile strdir.Text, True

End Sub

in c#

private void button1_Click(object sender, System.EventArgs e)

{

p.Settings.ScanSupport=Scan_Standard;

p.ScanFile("E:\\projects backup\\ankitclam
backup\\Clamtest\test\\hello.txt",True);

}

Scan_Standard and True are underlined and gives error

The name 'Scan_Standard'does not exist in class or namespace
'WebApplication1.Form1'
 
K

Kevin Yu [MSFT]

Hi Ankit,

Scan_Standard seems to be a predefined value in the COM library you're
referencing, Please add the namespace of the COM wrapper to Scan_Standard.
Like LibraryName.Scan_Standard.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
K

Kevin Yu [MSFT]

You're welcome.

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

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

Similar Threads


Top