471,350 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

casting in c# works sometimes

I have a c# client dll that calls a c# component on a server. When I register
the c# component on the server, everything works great. If the component is
not accessed for a while or I access it the next day, I get a Specified cast
is not valid error. If I reregister the server component, everything works
fine. The type is a runtime type that it cannot cast to at times. The code is

public HIS.CSRData.DataAccess CreateDataAccess()
//declare variable
HIS.CSRData.DataAccess da;

//declare type
Type oServer;

//set variable value
oServer = Type.GetTypeFromProgID("HIS.CSRData.DataAccess",

---this is where the error occurs
//set variable and create object
da = (HIS.CSRData.DataAccess)System.Activator.CreateIns tance(oServer);

//return value
return da;

Thanks in advance for any help.
Jul 21 '05 #1
0 709

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jacob Jensen | last post: by
35 posts views Thread by ytrama | last post: by
6 posts views Thread by Carlo Marchesoni | last post: by
reply views Thread by Keith | last post: by
7 posts views Thread by S. Lorétan | last post: by
14 posts views Thread by Daniel | last post: by
7 posts views Thread by William S Fulton | last post: by
32 posts views Thread by alex.j.k2 | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.