473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get_Range function throws an exception

I am communicating with Excel Interop dll using c#. The get_Range
function throws an exception if the parameters are invalid. For e.g.
get_Range("Miki l", Type.Missing); will crash if the "Mikil" named range
is not present.
Why the does the function crash instead of returning "null"?

May 25 '06 #1
5 9245
Mikil,

What is the exception that is being thrown?

Are you sure that is the line of code that is throwing the exception,
and that you aren't trying to access an object reference set to null?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mikil" <mi**********@g mail.com> wrote in message
news:11******** *************@i 39g2000cwa.goog legroups.com...
I am communicating with Excel Interop dll using c#. The get_Range
function throws an exception if the parameters are invalid. For e.g.
get_Range("Miki l", Type.Missing); will crash if the "Mikil" named range
is not present.
Why the does the function crash instead of returning "null"?

May 25 '06 #2
it throws a System.Runtime. InteropServices .COMException (0x800A03EC).

The exception is thrown on the following line :
ExcelApplicatio n.get_Range("Mi kil", Type.Missing); /// the
ExcelApplicatio n object is not null

May 25 '06 #3
Mikil,

What are the details of the exception? Any message or anything like
that?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mikil" <mi**********@g mail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
it throws a System.Runtime. InteropServices .COMException (0x800A03EC).

The exception is thrown on the following line :
ExcelApplicatio n.get_Range("Mi kil", Type.Missing); /// the
ExcelApplicatio n object is not null

May 25 '06 #4
Following the Exception :

"System.Runtime .InteropService s.COMException (0x800A03EC): Exception
from HRESULT: 0x800A03EC.\r\n at
Bently.System1. ExcelInterop._A pplication.get_ Range(Object Cell1, Object
Cell2)\r\n at PPExcelAddin.CE xcelUIHandler_M enuClick(Comman dBarButton
Ctrl, Boolean& CancelDefault) in o:\\ppexceladdi n\\ppexceladdin .cs:line
1033"

May 25 '06 #5
The arguments passed to the COM method are invalid, this results in an error
HRESULT (0x800A03EC) returned from the COM server. COM interop has to
translate all error HRESULTS in a COMException, this is part of the interop
protocol and is consistent with the native client COM protocol. You should
never assume there is something returned if HRESULT is not S_OK, there
isn't.

Willy.
"Mikil" <mi**********@g mail.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...
| Following the Exception :
|
| "System.Runtime .InteropService s.COMException (0x800A03EC): Exception
| from HRESULT: 0x800A03EC.\r\n at
| Bently.System1. ExcelInterop._A pplication.get_ Range(Object Cell1, Object
| Cell2)\r\n at PPExcelAddin.CE xcelUIHandler_M enuClick(Comman dBarButton
| Ctrl, Boolean& CancelDefault) in o:\\ppexceladdi n\\ppexceladdin .cs:line
| 1033"
|
May 25 '06 #6

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

Similar topics

12
1883
by: Eric Lilja | last post by:
Hello, I'm working with a hash table that is encapsulated in a class. One of its member functions insert() throws an exception if the insertion fails (for example, if the value was already present in the hash table). Now I have client code that looks like this: bool exception_thrown = false; try { hash_table.insert(some_value);
2
2951
by: Daniel | last post by:
if System.IO.StreamWriter write throws an exception, is there anyway to close the System.IO.StreamWriter object? it seems to stay open when this happens then future attempts to write to that same path fail because it says its in use by another process.
27
5649
by: sklett | last post by:
I just found myself doing something I haven't before: <code> public uint Duration { get { uint duration = 0; foreach(Thing t in m_things) { duration += t.Duration;
3
1718
by: benben | last post by:
I have always found Stroustrup's paper on generalized member function wrapper (http://www.research.att.com/~bs/wrapper.pdf) an interesting one. Recently I started to play with it. As I tried to put some extra data members (such as a std::vector) to the Call_proxy<class template it started to worry me because if the suffix in the destructor throws, there can be a memory leak. (See relevant code below) The Call_proxy<uses its own...
6
11593
by: Jack White | last post by:
Does anyone know if an analogue to the "swap()" function found in C++ exists in C#. For those not familiar, let's say you have a function that loads some collection passed in by reference. If an error occurs while loading then the collection will be in an indeterminate state. The work-around in C++ is to load a temporary collection first and once successful, invoke a (native) "swap()" function to exchange each object's internal "handle" to...
3
8016
by: Sugandh Jain | last post by:
Hi. How to write a function that will return me the factorial (say in a string) for the any positive integer it takes? When we find a factorial of even say 2000 or a higher number, it will be very big to be accomodated in int or long datatype. Regards, Sugandh
28
2857
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't apply. Can somebody tell me why? Thanks, Jess
6
1084
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
How do I know which exceptions a function throws? In my application, I make a call to DirectoryInfo.GetDirectories("\\NetworkPath\Path"). I check for System.IO.DirectoryNotFoundException and Security.SecurityException (which I found in the Object Browser with VS2005). If Path is invalid, the block catches System.IO.DirectoryNotFoundException as expected. However, if NetworkPath is invalid, it instead throws a System.IO.IOException,...
12
1825
by: raj s | last post by:
What is the advantage and disadvantage of using function declaration with exceptions specified. like foo()throws(char&)
0
9480
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
10329
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...
1
10092
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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...
1
7500
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
5381
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...
1
4053
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
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.