473,511 Members | 17,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A first chance exception of type 'System.InvalidCastException' occurred in scs.sr.dal.dll

Hi All

Here iam getting this Error "Specified cast is not valid."
My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error
I was calling this function in DALFactory class library(this library generate the DAL.dll)

Another class library has this function

public SecurityInfo Login(string username, string password)
{
IUserSetting us = SCS.SR.DALFactory.UserSetting.Create(); (When i was catch the Quick watch "SCS.SR.DALFactory.UserSetting.Create()" this that time iam getting this error "System.SystemException {"Specified cast is not valid."} System.SystemException ")

SecurityInfo getIsusreValid = us.IsUserValid(username,password);
return getIsusreValid;
}
public static SCS.SR.IDAL.IUserSetting Create()
{
string path = System.Configuration.ConfigurationSettings.AppSett ings["WebDAL"];
string className = path + ".UserSetting";
return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className); (Here Iam getting this error) (this is going to return the securityInfo function)

}

A first chance exception of type 'System.InvalidCastException' occurred in scs.sr.dal.dll

Additional information: Specified cast is not valid.
Regards,
Karunakara Rao.
Nov 16 '05 #1
3 8213
Hi,

In this line:

return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className)

Use CreateInstanceAndUnwrap instead of CreateInstance.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"karunakar" <ka***********@stcroixsystems.com> wrote in message news:Oi**************@TK2MSFTNGP15.phx.gbl...
Hi All

Here iam getting this Error "Specified cast is not valid."
My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error
I was calling this function in DALFactory class library(this library generate the DAL.dll)

Another class library has this function

public SecurityInfo Login(string username, string password)
{
IUserSetting us = SCS.SR.DALFactory.UserSetting.Create(); (When i was catch the Quick watch "SCS.SR.DALFactory.UserSetting.Create()" this that time iam getting this error "System.SystemException {"Specified cast is not valid."} System.SystemException ")

SecurityInfo getIsusreValid = us.IsUserValid(username,password);
return getIsusreValid;
}
public static SCS.SR.IDAL.IUserSetting Create()
{
string path = System.Configuration.ConfigurationSettings.AppSett ings["WebDAL"];
string className = path + ".UserSetting";
return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className); (Here Iam getting this error) (this is going to return the securityInfo function)

}

A first chance exception of type 'System.InvalidCastException' occurred in scs.sr.dal.dll

Additional information: Specified cast is not valid.
Regards,
Karunakara Rao.
Nov 16 '05 #2
Hi,

CreateInstanceAndUnwrap is a member of AppDomain , not of Assembly.
I would check the className to be a correct FQN of the class in question.

replace the line for this:

object tempO = Assembly.Load(path).CreateInstance(className);

and see in the watch window what tempO is.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:ep****************@TK2MSFTNGP14.phx.gbl...
Hi,

In this line:

return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className)

Use CreateInstanceAndUnwrap instead of CreateInstance.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"karunakar" <ka***********@stcroixsystems.com> wrote in message news:Oi**************@TK2MSFTNGP15.phx.gbl...
Hi All

Here iam getting this Error "Specified cast is not valid."
My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error
I was calling this function in DALFactory class library(this library generate the DAL.dll)

Another class library has this function

public SecurityInfo Login(string username, string password)
{
IUserSetting us = SCS.SR.DALFactory.UserSetting.Create(); (When i was catch the Quick watch "SCS.SR.DALFactory.UserSetting.Create()" this that time iam getting this error "System.SystemException {"Specified cast is not valid."} System.SystemException ")

SecurityInfo getIsusreValid = us.IsUserValid(username,password);
return getIsusreValid;
}
public static SCS.SR.IDAL.IUserSetting Create()
{
string path = System.Configuration.ConfigurationSettings.AppSett ings["WebDAL"];
string className = path + ".UserSetting";
return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className); (Here Iam getting this error) (this is going to return the securityInfo function)

}

A first chance exception of type 'System.InvalidCastException' occurred in scs.sr.dal.dll

Additional information: Specified cast is not valid.
Regards,
Karunakara Rao.
Nov 16 '05 #3
I agree - this is most likely the cause. I should have checked the Assembly's method list - shame on me!

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:ey**************@tk2msftngp13.phx.gbl...
Hi,

CreateInstanceAndUnwrap is a member of AppDomain , not of Assembly.
I would check the className to be a correct FQN of the class in question.

replace the line for this:

object tempO = Assembly.Load(path).CreateInstance(className);

and see in the watch window what tempO is.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:ep****************@TK2MSFTNGP14.phx.gbl...
Hi,

In this line:

return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className)

Use CreateInstanceAndUnwrap instead of CreateInstance.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"karunakar" <ka***********@stcroixsystems.com> wrote in message news:Oi**************@TK2MSFTNGP15.phx.gbl...
Hi All

Here iam getting this Error "Specified cast is not valid."
My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error
I was calling this function in DALFactory class library(this library generate the DAL.dll)

Another class library has this function

public SecurityInfo Login(string username, string password)
{
IUserSetting us = SCS.SR.DALFactory.UserSetting.Create(); (When i was catch the Quick watch "SCS.SR.DALFactory.UserSetting.Create()" this that time iam getting this error "System.SystemException {"Specified cast is not valid."} System.SystemException ")

SecurityInfo getIsusreValid = us.IsUserValid(username,password);
return getIsusreValid;
}
public static SCS.SR.IDAL.IUserSetting Create()
{
string path = System.Configuration.ConfigurationSettings.AppSett ings["WebDAL"];
string className = path + ".UserSetting";
return (SCS.SR.IDAL.IUserSetting) Assembly.Load(path).CreateInstance(className); (Here Iam getting this error) (this is going to return the securityInfo function)

}

A first chance exception of type 'System.InvalidCastException' occurred in scs.sr.dal.dll

Additional information: Specified cast is not valid.
Regards,
Karunakara Rao.
Nov 16 '05 #4

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

Similar topics

1
6355
by: Ben | last post by:
Hi I have a program that has just been developed on a machine running VS .NET 2003, we installed VS6 on the same machine and now we receive the below error on click event. The on click event...
3
31116
by: Pieter | last post by:
Hi, I have a Windows Forms application (VB.NET 2.0) which uses a Class Library in C#. The application runs fine, but when I run it in debug mode, I get several "A first chance exception of type...
1
1671
by: Tommy | last post by:
I get this message in the output window of my app I just converted from VS 2003 to 2005. It's a VB.Net app. A first chance exception of type 'System.InvalidCastException' occurred in...
4
2046
by: Lammert | last post by:
Good afternoon, I have a very strange problem. When I execute the code below the program throws an InvalidCastException. When I debug the code I see e.Item.DataItem is an object from the type...
7
15659
by: illegal.prime | last post by:
Hi all, I've got a client/server application and just wanted to ensure that this is expected behavior. I recently set the following configuration in Visual Studio: Debug->Exceptions->Break Into...
3
22358
by: GS | last post by:
why am i getting A first chance exception of type 'System.NullReferenceException' occurred in myapp.exe below? and what can i do get rid of it? Private Function getPrefxType() As String If...
7
1812
by: Pixel.to.life | last post by:
Gurus, Another question on one of the coveted Microsoft products: JIT debugger with VS2005. I have a managed app that builds great on one machine (Vista Home basic, VS2005, JIT enabled for...
0
1400
by: Pixel.to.life | last post by:
Gurus, Another question on one of the coveted Microsoft products: JIT debugger with VS2005. I have a managed app that builds great on one machine (Vista Home basic, VS2005, JIT enabled for...
6
4763
by: zubair1 | last post by:
Hi, Today, i added some new code which was to see if a file is locked or not (in use by another application). While i did that it was showing me some errors like in the Output window:- A first...
0
7242
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
7138
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
7355
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,...
0
7423
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...
1
7081
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
5668
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,...
1
5066
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...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
447
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...

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.