473,791 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8161
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.c om...
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*******@news groups.nospam> wrote in message
news:uw******** *****@tk2msftng p13.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(objS heet.Cells(i, j), Excel.Range).Nu mberFormat = "@"

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.Applicati on
Dim XLWorkbook As Excel.Workbook
Dim XLworkbooks As Excel.Workbooks
XLApplication = CType(CreateObj ect("Excel.Appl ication"),
Excel.Applicati on)
XLworkbooks = DirectCast(XLAp plication.Workb ooks, Excel.Workbooks )
XLWorkbook = DirectCast(XLwo rkbooks.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
1639
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 try to retrieve the string. Now I'd rather not turn off option strict but I'd also prefer to have my connection string in one place. Does anyone have any ideas where I'm going wrong with this? This is the code In Web.Config (I've removed some...
12
1536
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 to explicitly cast or convert data when comparing/setting two different data types right?
4
398
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 Strict Off, how do I get rid of this error? The code example is below... Dim oExcel As Object Dim oBook As Object Dim oSheet As Object
3
2006
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 eventArgs As System.EventArgs) Handles optWithTone.CheckedChanged If eventSender.Checked Then pAlarmOption = NokiaCLCalendar.CalendarAlarmType.CALENDAR_ALARM_WITH_TONE
7
2130
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" HeaderStyle-Font-Bold="True" CellPadding="0" CellSpacing="1" Font-Size="Small" BackColor="Transparent" ForeColor="Black"
1
2370
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 Strict On disallows late binding." This references line 1, which is my page directive:
6
423
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 "Option Strict On disallows late binding" errors (see below) How might I fix this ?
7
3379
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 baffled. I am getting the error "option Strict On disallows late binding", and the error is referring to this line of code: (3rd line in my sub below) Select Case sender.Parent.ID
0
1296
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 "Option Strict On disallows late binding" If I comment out the line and get to that place in the debugger, I can pull
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.