ZopoStyle

Hi,

Does anyone knows how can I use the " # " in C# just like this function in vb6

#If AMBIENTE_EMPRESA Then
Set gbLog = CreateObject("LogOnline.wILog")
With gbLog
.IniciarLog "PROGED"
.GravarLog "001", vbLogEventTypeInformation, "Preparando Processo de Envio de Email's e Bip"
End With
#End If

And what the # mark means

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

And this one is it possible to use in c# also

Set gbLog = CreateObject("LogOnline.wILog")

Thanks




Re: Visual C# Language VB6 # mark in C#

Ashish Basran

As per my knowledge, you cannot use # as you used in the function in c# and CreateObject too will not work

The `#' is followed by an identifier that is the directive name. For example, `#define' is the directive






Re: Visual C# Language VB6 # mark in C#

ZopoStyle

OK,

But from where does the program takes the value for the AMBIENTE_EMPRESA variable

I do not declare it anywhere in the code...

(It's a system that I might upgrade to .net)

Thanks






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

Have a look at following article. It's nice, should help you understand directives

http://www.c-sharpcorner.com/UploadFile/vgupta/PreprocessorDirectivesCS11162005235503PM/PreprocessorDirectivesCS.aspx






Re: Visual C# Language VB6 # mark in C#

ZopoStyle

Thanks, I'm gonna test it here..

I think it's solved my problem...

There is just missing the crete object problem !!






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

I am not sure but may be Activator.CreateInstance("assemblyName", "typeName") could get you the functionality you looking for






Re: Visual C# Language VB6 # mark in C#

ZopoStyle

It doesn't work, I can't get methods from the component...






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

May be something like following

MyClass obj = Activator.CreateInstance("assemblyName", "typeName"); //where the type is MyClass

then

obj.MyMethod()....






Re: Visual C# Language VB6 # mark in C#

ZopoStyle

Let me put an example... Idon't know if I'm doing something wrong...

My Component Is registered under "MediControl" name.... one object for example is ACEGAC.clsAdmDBConsultas

So I'm using this code

clsAdmDBConsultas test = Activator.CreateInstance(Type.GetType("ACEGAC.clsAdmDBConsultas"), "clsAdmDBConsultas");

When I try to compile I get this error code "The type or namespace name 'clsAdmDBConsultas' could not be found (are you missing a using directive or an assembly reference )"

Thanks anyway for helping






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

ACEGAC.clsAdmDBConsultas may be the type (assuming ACEGAC is namespace)

Well, try following

clsAdmDBConsultas test = Activator.CreateInstance(Type.GetType("ACEGAC.clsAdmDBConsultas"));

I am assuming that Type.GetType("ACEGAC.clsAdmDBConsultas") is working fine and returning you the type info.






Re: Visual C# Language VB6 # mark in C#

ZopoStyle

Yeah, It's right.... But it's still aking for the assembly reference...

The enviroment is the following, I have a dll made in VB6, and registered in Windows Component Service, and I need to use it on my C# application...

What you've said is right, but why don't it work






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

Your dll is in VB6. I think then you need to have interop.... Well, have you added the reference using Add Reference The add reference might create interop reference for you(I am not sure, I have nerver tried that).




Re: Visual C# Language VB6 # mark in C#

ZopoStyle

I don't know the DLL, it's exclusive in the client enviroment, He can't inform to me, where it is, and he also can't send me the dll....I need to program using only the methods given...

Is it possible to do Or to get the path, from the component service and register it on the execution time






Re: Visual C# Language VB6 # mark in C#

Ashish Basran

I am not sure if you can get path etc. I have never worked on that. Well, if it is possbile to add reference then it will be great..... and you will be able to use the dll the way you want...




Re: Visual C# Language VB6 # mark in C#

ZopoStyle

OK, thanks