473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

option strict on

hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for
this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of class to
interface ) ,so the option strict will be ON, but implict coversion between
class and interface will not generate compile error ?
Nov 20 '05 #1
11 2089
"Daylor" <ro******@hotmail.com> schrieb
hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are
implict conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar,
just for this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of
class to interface ) ,so the option strict will be ON, but implict
coversion between class and interface will not generate compile error
?

I don't see the problem. The following code works:

Public Interface icar
Sub test()
End Interface

Public Class ccar
Implements icar

Public Sub test() Implements icar.test
End Sub
End Class
'...
Dim o As icar
o = New ccar 'no problem with option strict on
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "Daylor" <ro******@hotmail.com> scripsit:
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for
this reason to do : ICar = new CCar.


I am not able to repro that in VB.NET 2003.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Daylor,
Can you post your code for CCar & ICar or preferable a small sample such as
Armin's

As Armin demonstrated & Herfried stated, This functions as you expect in
both VB.NET 2002 & VB.NET 2003!

When CCar Implements ICar:

If I have:
Dim ic As ICar
Dim car As CCar

The following will work with Option Strict On
ic = car

The following may not succeed as other classes may implement ICar
car = ic

So you need to check the type of the object & DirectCast to succeed.
If TypeOf ic Is CCar Then
car = DirectCast(ic, CCar)
End If

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for
this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of class to interface ) ,so the option strict will be ON, but implict coversion between class and interface will not generate compile error ?

Nov 20 '05 #4
hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly (vb.net)
and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i
get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in namespace,and
CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is interface
he is implement
================================================


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Daylor,
Can you post your code for CCar & ICar or preferable a small sample such as Armin's

As Armin demonstrated & Herfried stated, This functions as you expect in
both VB.NET 2002 & VB.NET 2003!

When CCar Implements ICar:

If I have:
Dim ic As ICar
Dim car As CCar

The following will work with Option Strict On
ic = car

The following may not succeed as other classes may implement ICar
car = ic

So you need to check the type of the object & DirectCast to succeed.
If TypeOf ic Is CCar Then
car = DirectCast(ic, CCar)
End If

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of
class to
interface ) ,so the option strict will be ON, but implict coversion

between
class and interface will not generate compile error ?


Nov 20 '05 #5
HI AGAIN.
one more thing, when im doing it in the same assembly.
i dont have an error.
meaning , when sending a CCar class ,to sub the recive ICar ,in the assembly
that have the CCar class.
(the ICar is in other assembly ) , its works fine. no errors.
for some reason, if i do it , like i want to do,(describe way i have the
solution in the last post ) , i recive an error.

----------------------------------------------------
now, i thought maybe i have problem with referencing the same interface.dll
assembly.
i try to point from each project to the interface.dll , in 1 project i get
an error, that the project can't copy the dll,
cause other process use it.


"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly (vb.net) and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i
get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in namespace,and CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is interface he is implement
================================================


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Daylor,
Can you post your code for CCar & ICar or preferable a small sample such

as
Armin's

As Armin demonstrated & Herfried stated, This functions as you expect in
both VB.NET 2002 & VB.NET 2003!

When CCar Implements ICar:

If I have:
Dim ic As ICar
Dim car As CCar

The following will work with Option Strict On
ic = car

The following may not succeed as other classes may implement ICar
car = ic

So you need to check the type of the object & DirectCast to succeed.
If TypeOf ic Is CCar Then
car = DirectCast(ic, CCar)
End If

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of

class
to
interface ) ,so the option strict will be ON, but implict coversion

between
class and interface will not generate compile error ?



Nov 20 '05 #6

"Daylor" <ro******@hotmail.com> schrieb im Newsbeitrag
news:bp**********@news2.netvision.net.il...
hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly (vb.net) and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i
get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in namespace,and CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is interface he is implement
================================================

I do understand you but I can not reproduce the problem. The following code
works:
Public Interface ICar
Sub test()
End Interface

Public Class CCar
Implements ICar

Public Sub test() Implements ICar.test
End Sub
End Class

Public Class Garage
Public Sub SendToRepair(ByVal Car As ICar)

End Sub
End Class
'...

Dim o As ICar
Dim g As New Garage

o = New CCar
g.SendToRepair(o)

Maybe you define the interface ICar or the CClas twice, i.e. in different
assemblies?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
Daylor,
Does the MyGarage.dll, MyApp.dll or TestApp.exe define its own ICar
interface or does it reference the MyInterfaces.dll and get ICar from there?
(From what you said it is suppose to get it from MyInterfaces.dll, sometimes
developers cut & past the interface to their project by mistake.
[MyGarage.dll]MyInterfaces.ICar is different then
[MyApp.dll]MyInterfaces.ICar.

Does TestApp.exe reference all three dlls? Does MyGarage.dll & MyApp.dll
reference MyInterfaces.dll?

Are you certain that the assemblies are being built in the proper order?
1. MyInterfaces.dll
2. MyApp.dll
3. MyGarage.dll
4. TestApp.exe

Note 2 & 3 can be reversed, however MyInterfaces.dll must be first & TestApp
must be last.

Are you certain that you are referencing the correct version of the
assemblies? In other words you do not have an old copy of an assembly that
you are referencing.

Is this four solutions each with a project, or one solution with four
projects?

If this is one solution are you referencing the project or the dll in the
other projects?

Is this VS.NET 2002 or VS.NET 2003?
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is interface he is implement If you use Option Strict Off, will it run? I would expect a runtime error on
that line as it appears that the ICar in TextApp is different then the ICar
in MyGarage.dll, hence the compile error with Option Strict On. In other
words the error is because you have a second definition of ICar someplace
which is not the ICar that CCar is using!

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il... hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly (vb.net) and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i
get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in namespace,and CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is interface he is implement
================================================


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Daylor,
Can you post your code for CCar & ICar or preferable a small sample such

as
Armin's

As Armin demonstrated & Herfried stated, This functions as you expect in
both VB.NET 2002 & VB.NET 2003!

When CCar Implements ICar:

If I have:
Dim ic As ICar
Dim car As CCar

The following will work with Option Strict On
ic = car

The following may not succeed as other classes may implement ICar
car = ic

So you need to check the type of the object & DirectCast to succeed.
If TypeOf ic Is CCar Then
car = DirectCast(ic, CCar)
End If

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi.
im using option strict on.
im doing in ,from the simple reason ,to be warn when there are implict
conversion like string to int ,int to string.

BUT.
the price ,(now i see ), is very bad.
if i have class CCar and interface ICar
when im doing this :
ICar = new CCar
i get compiler error,because the option strict on.
i thought ,the compiler can "see", the ccar is implementing ICar, just for this reason to do : ICar = new CCar.
the question :
is there a middle way (im not talking about explicit converstion of

class
to
interface ) ,so the option strict will be ON, but implict coversion

between
class and interface will not generate compile error ?



Nov 20 '05 #8
Ok, now its ok, no more error , after i did that :
remove the Interface.Dll project from the solution.

================================================== ========
"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
HI AGAIN.
one more thing, when im doing it in the same assembly.
i dont have an error.
meaning , when sending a CCar class ,to sub the recive ICar ,in the assembly that have the CCar class.
(the ICar is in other assembly ) , its works fine. no errors.
for some reason, if i do it , like i want to do,(describe way i have the
solution in the last post ) , i recive an error.

----------------------------------------------------
now, i thought maybe i have problem with referencing the same interface.dll assembly.
i try to point from each project to the interface.dll , in 1 project i get
an error, that the project can't copy the dll,
cause other process use it.


"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly

(vb.net)
and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in

namespace,and
CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is

interface
he is implement
================================================


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Daylor,
Can you post your code for CCar & ICar or preferable a small sample such
as
Armin's

As Armin demonstrated & Herfried stated, This functions as you expect
in both VB.NET 2002 & VB.NET 2003!

When CCar Implements ICar:

If I have:
Dim ic As ICar
Dim car As CCar

The following will work with Option Strict On
ic = car

The following may not succeed as other classes may implement ICar
car = ic

So you need to check the type of the object & DirectCast to succeed.
If TypeOf ic Is CCar Then
car = DirectCast(ic, CCar)
End If

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
> hi.
> im using option strict on.
> im doing in ,from the simple reason ,to be warn when there are implict > conversion like string to int ,int to string.
>
> BUT.
> the price ,(now i see ), is very bad.
> if i have class CCar and interface ICar
> when im doing this :
> ICar = new CCar
> i get compiler error,because the option strict on.
>
>
> i thought ,the compiler can "see", the ccar is implementing ICar,

just for
> this reason to do : ICar = new CCar.
>
>
> the question :
> is there a middle way (im not talking about explicit converstion of

class
to
> interface ) ,so the option strict will be ON, but implict coversion
between
> class and interface will not generate compile error ?
>
>



Nov 20 '05 #9
Now i got it :)
i return the interface.dll project to the solution.
go to the config manager,and remove the build checkbox!!!!!!!! from the
interface project. .

:)
this is REAL SOLUTION.

the compiler errors are not so good :)

================================================== ===========
"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
Ok, now its ok, no more error , after i did that :
remove the Interface.Dll project from the solution.

================================================== ========
"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
HI AGAIN.
one more thing, when im doing it in the same assembly.
i dont have an error.
meaning , when sending a CCar class ,to sub the recive ICar ,in the assembly
that have the CCar class.
(the ICar is in other assembly ) , its works fine. no errors.
for some reason, if i do it , like i want to do,(describe way i have the
solution in the last post ) , i recive an error.

----------------------------------------------------
now, i thought maybe i have problem with referencing the same

interface.dll
assembly.
i try to point from each project to the interface.dll , in 1 project i get
an error, that the project can't copy the dll,
cause other process use it.


"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
hi again.
im sure of what im asking here.

i try it again, and compare what the first sender post.

ill explain with more details :
the classes names,is just to be more clear :

i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
i have the CCar class the implements ICar in the MyApp.dll assembly

(vb.net)
and i have Garage class in the MyGarage.dll assembly (Managed c++ )

now , i have TestApp.exe (vb.net ) that create this CCar :

private m_ccar as CCar

public sub MySub ()
m_ccar = new CCar
m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here i get an error, the option strict is on ,and not allow this converstion.

end sub

now, one more thing,i just want to say,is that the ICar is in namespace,and
CCar is not.just saying this for the info.
so the error i get is like this :
"Option Strict On disallows implicit conversions from CCar to
MyInterfaces.ICar"

================================================
hope u can help me with that, cause from the start i didnt belive that
option strict on , will not let me send type to paramater that is

interface
he is implement
================================================


"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> Daylor,
> Can you post your code for CCar & ICar or preferable a small sample such as
> Armin's
>
> As Armin demonstrated & Herfried stated, This functions as you
expect in > both VB.NET 2002 & VB.NET 2003!
>
> When CCar Implements ICar:
>
> If I have:
> Dim ic As ICar
> Dim car As CCar
>
> The following will work with Option Strict On
> ic = car
>
> The following may not succeed as other classes may implement ICar
> car = ic
>
> So you need to check the type of the object & DirectCast to succeed.
> If TypeOf ic Is CCar Then
> car = DirectCast(ic, CCar)
> End If
>
> Hope this helps
> Jay
>
> "Daylor" <ro******@hotmail.com> wrote in message
> news:bp**********@news2.netvision.net.il...
> > hi.
> > im using option strict on.
> > im doing in ,from the simple reason ,to be warn when there are implict > > conversion like string to int ,int to string.
> >
> > BUT.
> > the price ,(now i see ), is very bad.
> > if i have class CCar and interface ICar
> > when im doing this :
> > ICar = new CCar
> > i get compiler error,because the option strict on.
> >
> >
> > i thought ,the compiler can "see", the ccar is implementing ICar, just for
> > this reason to do : ICar = new CCar.
> >
> >
> > the question :
> > is there a middle way (im not talking about explicit converstion

of class
> to
> > interface ) ,so the option strict will be ON, but implict coversion > between
> > class and interface will not generate compile error ?
> >
> >
>
>



Nov 20 '05 #10
Daylor,
It sounds like you are simply avoiding the problem with out finding the
"solution", which my series of questions were intended to help find a
solution for you.

I normally reference the Project and not the DLL when I have multiple
projects in a solution, this will cause VS.NET to build things in the proper
order.

Alternatively (in addition to?) you can use Project - Dependencies to set
which projects in your solution are dependent on which other projects. I
find referencing the project in a solution sets the dependencies correctly.

I've seen others mention that a dll in use, however I have not experienced
it personally. Most of the time I have heard about it, it has been projects
referencing the DLL itself as opposed to the project. Try referencing the
project to see if that makes a difference.

Hope this helps
Jay

"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
Now i got it :)
i return the interface.dll project to the solution.
go to the config manager,and remove the build checkbox!!!!!!!! from the
interface project. .

:)
this is REAL SOLUTION.

the compiler errors are not so good :)

================================================== ===========
"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
Ok, now its ok, no more error , after i did that :
remove the Interface.Dll project from the solution.

================================================== ========
"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
HI AGAIN.
one more thing, when im doing it in the same assembly.
i dont have an error.
meaning , when sending a CCar class ,to sub the recive ICar ,in the

assembly
that have the CCar class.
(the ICar is in other assembly ) , its works fine. no errors.
for some reason, if i do it , like i want to do,(describe way i have the solution in the last post ) , i recive an error.

----------------------------------------------------
now, i thought maybe i have problem with referencing the same

interface.dll
assembly.
i try to point from each project to the interface.dll , in 1 project i get an error, that the project can't copy the dll,
cause other process use it.


"Daylor" <ro******@hotmail.com> wrote in message
news:bp**********@news2.netvision.net.il...
> hi again.
> im sure of what im asking here.
>
> i try it again, and compare what the first sender post.
>
> ill explain with more details :
> the classes names,is just to be more clear :
>
> i have the ICar interface in MyInterfaces.dll assemly. (vb.net)
> i have the CCar class the implements ICar in the MyApp.dll assembly
(vb.net)
> and i have Garage class in the MyGarage.dll assembly (Managed c++ )
>
> now , i have TestApp.exe (vb.net ) that create this CCar :
>
> private m_ccar as CCar
>
> public sub MySub ()
> m_ccar = new CCar
> m_garage.SendToRepair (m_ccar) // m_garage expect ICar !! ,and here
i
> get an error, the option strict is on ,and not allow this converstion. >
> end sub
>
> now, one more thing,i just want to say,is that the ICar is in
namespace,and
> CCar is not.just saying this for the info.
> so the error i get is like this :
> "Option Strict On disallows implicit conversions from CCar to
> MyInterfaces.ICar"
>
> ================================================
> hope u can help me with that, cause from the start i didnt belive that > option strict on , will not let me send type to paramater that is
interface
> he is implement
> ================================================
>
>
>
>
> "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in
message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
> > Daylor,
> > Can you post your code for CCar & ICar or preferable a small sample
such
> as
> > Armin's
> >
> > As Armin demonstrated & Herfried stated, This functions as you expect
in
> > both VB.NET 2002 & VB.NET 2003!
> >
> > When CCar Implements ICar:
> >
> > If I have:
> > Dim ic As ICar
> > Dim car As CCar
> >
> > The following will work with Option Strict On
> > ic = car
> >
> > The following may not succeed as other classes may implement ICar
> > car = ic
> >
> > So you need to check the type of the object & DirectCast to

succeed. > > If TypeOf ic Is CCar Then
> > car = DirectCast(ic, CCar)
> > End If
> >
> > Hope this helps
> > Jay
> >
> > "Daylor" <ro******@hotmail.com> wrote in message
> > news:bp**********@news2.netvision.net.il...
> > > hi.
> > > im using option strict on.
> > > im doing in ,from the simple reason ,to be warn when there are

implict
> > > conversion like string to int ,int to string.
> > >
> > > BUT.
> > > the price ,(now i see ), is very bad.
> > > if i have class CCar and interface ICar
> > > when im doing this :
> > > ICar = new CCar
> > > i get compiler error,because the option strict on.
> > >
> > >
> > > i thought ,the compiler can "see", the ccar is implementing

ICar, just
> for
> > > this reason to do : ICar = new CCar.
> > >
> > >
> > > the question :
> > > is there a middle way (im not talking about explicit converstion

of > class
> > to
> > > interface ) ,so the option strict will be ON, but implict coversion > > between
> > > class and interface will not generate compile error ?
> > >
> > >
> >
> >
>
>



Nov 20 '05 #11
It sounds, as someone suggested, that you have the interface iCar defined
in both the MyInterfaces Dll and the MyGarage Dll - you should have only
one definition, probably in MyInterfaces.dll and reference that project
from both the MyGarage.Dll and the MyApp.Dll
if you have two definitions, they will act as different types, even though
they have the same name - not referencing the MyInterfaces.Dll or setting
the project to not build works but isn't a solution - it just means that
the MyInterfaces.Dll isn't being used at all.

Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
15
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this is...
13
by: C. Moya | last post by:
I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem to figure out if it has been fixed or not. It still seems we have to add the declaration at the top...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
18
by: Poldie | last post by:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1. In my web.config I have: <compilation debug="true" strict="true" /> In my Tools/Options/Projects and solutions/vb defaults...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.