G
Guest
Summary: I've got some *.ASPX pages that still use COM objects. I'd like to
enable Option Strict, but I get "error BC30574: Option Strict On disallows
late binding" errors. How can I bypass this problem WITHOUT moving my code
out of the *.ASPX page or pre-compiling it, and WITHOUT rewriting the COM
objects as managed .NET code?
Disclaimer: I understand there is a performance penalty when accessing COM
objects from managed code, and long to convert these objects to managed code
one day. However, that is not an option right now. Also, I understand there
are benefits to pre-compiled code-behind files, however again I'm hoping for
a solution without involving new code-behinds.
Example:
Let's say I'm writing a VB.NET application using Visual Studio, and I want
to instantiate the COM class "FruitBasket.CAppleBasket". I don't need to use
a CreateObject call to do this!
First, I'd add that COM object to my project's "References" folder, as a COM
reference.
Second, presumably, I could write code like:
Dim oBasket as New FruitBasket.CAppleBasket
Okay, great, so that's the VB.NET/Visual Studio world as I understand it,
which seems to thwart complaints of late binding (please correct me if I'm
wrong).
Now, let's look at a snippet of my (pretend) ASPX page!
<%
Dim oBasket as Object = Server.CreateObject("FruitBasket.CAppleBasket")
oBasket.setColor("red")
%>
If my @Page directive sets Strict="True", then I see compilation errors like
"error BC30574: Option Strict On disallows late binding".
So I'm left wondering, what (if anything) can I do to prevent late binding
to these COM objects without significant code changes? Is there a Web.config
entry, or @Import directive I can use for this?
Thanks!
enable Option Strict, but I get "error BC30574: Option Strict On disallows
late binding" errors. How can I bypass this problem WITHOUT moving my code
out of the *.ASPX page or pre-compiling it, and WITHOUT rewriting the COM
objects as managed .NET code?
Disclaimer: I understand there is a performance penalty when accessing COM
objects from managed code, and long to convert these objects to managed code
one day. However, that is not an option right now. Also, I understand there
are benefits to pre-compiled code-behind files, however again I'm hoping for
a solution without involving new code-behinds.
Example:
Let's say I'm writing a VB.NET application using Visual Studio, and I want
to instantiate the COM class "FruitBasket.CAppleBasket". I don't need to use
a CreateObject call to do this!
First, I'd add that COM object to my project's "References" folder, as a COM
reference.
Second, presumably, I could write code like:
Dim oBasket as New FruitBasket.CAppleBasket
Okay, great, so that's the VB.NET/Visual Studio world as I understand it,
which seems to thwart complaints of late binding (please correct me if I'm
wrong).
Now, let's look at a snippet of my (pretend) ASPX page!
<%
Dim oBasket as Object = Server.CreateObject("FruitBasket.CAppleBasket")
oBasket.setColor("red")
%>
If my @Page directive sets Strict="True", then I see compilation errors like
"error BC30574: Option Strict On disallows late binding".
So I'm left wondering, what (if anything) can I do to prevent late binding
to these COM objects without significant code changes? Is there a Web.config
entry, or @Import directive I can use for this?
Thanks!