473,396 Members | 2,090 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,396 software developers and data experts.

Option Strict On disallows late binding.

Hi all,

I use VB.net 2003 and want to export data to Excel. Target PCs still
have Office 2000 so I could not use Microsofts PIAs. Instead I use the
included Excel 10 COM DLL from Microsoft. Everything works fine.

Now I want to sign my application with a strong name. Therefore I also
need to sign all DLLs. So I searched through the web and found
information that I need to use tlbimp, and the source file is
'xl5en32.olb'. Now this also works fine.

But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?
Dec 16 '05 #1
4 8128
Heinz wrote:
Hi all,

I use VB.net 2003 and want to export data to Excel. Target PCs still
have Office 2000 so I could not use Microsofts PIAs. Instead I use the
included Excel 10 COM DLL from Microsoft. Everything works fine.

Now I want to sign my application with a strong name. Therefore I also
need to sign all DLLs. So I searched through the web and found
information that I need to use tlbimp, and the source file is
'xl5en32.olb'. Now this also works fine.

But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?


In what code does DirectCast not work? CType() is another less strict
version of directcast, it may solve your problem.

Chris
Dec 16 '05 #2
"Heinz" <He***********@NoSpam.de> wrote in message
news:2g********************************@4ax.com...
But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?


I've skirted this issue by moving my Excel late binding stuff into a
separate class files that has Option Strict Off.

I have code like this (see below), that I have not figured out yet how to
use Option Strict On w/ DirectCast. :(

Dim objSheet As Excel.Worksheet
....
objSheet.Cells(i, j).NumberFormat = "@" 'Option Strict On disallows late
binding error here

I'm interested in hearing others ideas as well.

Greg
Dec 16 '05 #3
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:uw*************@tk2msftngp13.phx.gbl...
I have code like this (see below), that I have not figured out yet how to
use Option Strict On w/ DirectCast. :(

Dim objSheet As Excel.Worksheet
...
objSheet.Cells(i, j).NumberFormat = "@" 'Option Strict On disallows late
binding error here


Nevermind...

DirectCast(objSheet.Cells(i, j), Excel.Range).NumberFormat = "@"

That does seems to be what I needed to allow Option Strict On. :)

Greg
Dec 16 '05 #4
On Fri, 16 Dec 2005 09:52:48 -0500, Chris <no@spam.com> wrote:
In what code does DirectCast not work? CType() is another less strict
version of directcast, it may solve your problem.


Hi Chris,

so I now modified my code and could save it even with options strict
on. But the export does not work.

I've now added the following code:

Dim XLApplication As Excel.Application
Dim XLWorkbook As Excel.Workbook
Dim XLworkbooks As Excel.Workbooks
XLApplication = CType(CreateObject("Excel.Application"),
Excel.Application)
XLworkbooks = DirectCast(XLApplication.Workbooks, Excel.Workbooks)
XLWorkbook = DirectCast(XLworkbooks.Add, Excel.Workbook)

Application crashes on second executed statement 'XLWorkbooks = ....'
with Error message 'Member not found'.....?? (Same if I use CTYPE
instead of DirectCast) So I'm also not sure whether it was correct to
sign the specified .olb file and use this one then...
Dec 19 '05 #5

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

Similar topics

1
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I...
12
by: Simon Harris | last post by:
Hi All, I've been advised to use option strict. I've tried to read up on this, all i can find is that it... "disallows implicit narrowing conversions" This kinda makes sense - Means I have...
4
by: KC | last post by:
I'm trying to export data to Excel, and I found an example routine at microsoft, but I get an "Option Strict On disallows late binding." at 'oBook = oExcel.Workbooks.Add'. Without turning Option...
3
by: Starbuck | last post by:
Hi The following generates an error when Option Strict is On Can anytell tell me how to get round this please. Private Sub optWithTone_CheckedChanged(ByVal eventSender As System.Object, ByVal...
7
by: Owen Mortensen | last post by:
(This code was working in asp.net 1.1 VS2003. After upgrade to VS2005, chokes): in the aspx file: <ItemTemplate> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"...
1
by: Adotek | last post by:
Hi All, I've just converted a solution from .Net v1.1 to v2.0, by allowing Visual Studio 2005 to do the conversion. Since doing so, I am getting a compilation error as follows: "Option...
6
by: Rob | last post by:
I have employed a "Singleton mode" of programming for this project. I have a class that exposes some properties of the class "Sample" to other forms.... If I set Option Strict On, I get many...
7
by: Lynn | last post by:
Hello, I have a website that is working fine. I have just turned on "option strict" and am getting an error with the parts of my code. I have fixed everything but this section, which has me...
0
by: Ronald S. Cook | last post by:
Hi, I'm wanting to iterate over a generic IList, but the code won't compile because the blue sqiggle line under: _DataRow("SecurityFunctionName") = _IList(i).SecurityFunctionName; sez...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.