Ask a Question related to ASP.NET Web Services, Design and Development.
-
Scott Reynolds #1
Inheriting from the CollectionBase causes weird Error: System.IO.FileNotFoundException
I am having a problem exposing a class inherited from the collection base
class as a webservice. If I expose the collection on a web page all works
well and I am very happy.
However when I try and expose this via a web service I get a weird error
saying that the dll could not be found. The specific error is:
I can't figure it out. I thought it was to do with reflection but I am able
to load and view the webservice definition which correctly shows the defn to
be returned. Any webservice I try to instantiate displays this error.
All the details are below.
----------------------------------------------------------------------------
--------
Error Trace
----------------------------------------------------------------------------
--------
System.IO.FileNotFoundException: File or assembly name ytuiu77l.dll, or one
of its dependencies, was not found.
File name: "ytuiu77l.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean
throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef,
Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence
assemblySecurity)
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer.FromMapping s(XmlMapping[]
mappings)
at
System.Web.Services.Protocols.XmlReturn.GetInitial izers(LogicalMethodInfo[]
methodInfos)
at
System.Web.Services.Protocols.XmlReturnWriter.GetI nitializers(LogicalMethodI
nfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetIni tializers(Type type,
LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor (Type type)
at System.Web.Services.Protocols.HttpServerProtocol.I nitialize()
at System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
----------------------------------------------------------------------------
-----------------
Broken Web Service Code: trying to return the Users Collection
----------------------------------------------------------------------------
-----------------
[WebMethod]
public Users GetFilteredUsers(string filter)
{
SqlDataReader reader =
SqlHelper.ExecuteReader(_connectionString,"vt_sele ctUsers",filter);
Users users = new Users(reader);
return users;
}
----------------------------------------------------------------------------
-----------------
Working Web Service Code: Returns a single User
----------------------------------------------------------------------------
-----------------
[WebMethod]
public User GetFilteredUsers(string filter)
{
SqlDataReader reader =
SqlHelper.ExecuteReader(_connectionString,"vt_sele ctUsers",filter);
Users users = new Users(reader);
return users[0];
}
----------------------------------------------------------------------------
-----------------
Working Web Service Code: Returns an Int
----------------------------------------------------------------------------
-----------------
[WebMethod]
public int GetFilteredUsers(string filter)
{
SqlDataReader reader =
SqlHelper.ExecuteReader(_connectionString,"vt_sele ctUsers",filter);
Users users = new Users(reader);
int no = 1;
foreach(User u in users)
{
Debug.Write(u.Email.ToString());
}
return no;
}
----------------------------------------------------------------------------
-----------------
Collection Base Code
----------------------------------------------------------------------------
-----------------
public class Users: System.Collections.CollectionBase
{
public Users(IDataReader Reader){Fill(Reader);}
public void Fill(IDataReader reader){
while(reader.Read())
{
User user = new
User(reader["name"].ToString(),reader["email"].ToString());
Add(user);
}
}
public void Add(User aUser)
{
List.Add(aUser);
}
public bool Remove(int index)
{
if (index > Count - 1 || index < 0)
{
return false;
}
else
{
List.RemoveAt(index);
return true;
}
}
public User this[int Index]
{
get {
try
{
return (User)List[Index];
}
catch
{
return null;
}
}
set{}
}
}
----------------------------------------------------------------------------
--------
User Class Code
----------------------------------------------------------------------------
--------
public class User
{
private string name;
private string email;
public User(){
name = "";
email = "";
}
public User(string Name, string Email){
name = Name;
email = Email;
}
public string Name{
get{return name;}
set{name = value;}
}
public string Email{
get{return email;}
set{email = value;}
}
}
Scott Reynolds Guest
-
System.IO.FileNotFoundException using file.copy
I am trying to copy a file to a network drive. I can do it on the domain controller/web server but not from a client. Here is the code: Dim... -
Serialiazing CollectionBase
Hello... I the following class deriving from CollectionBase: ============================ public class YYYepC :... -
Weird spike in System time every 5:00 minutes...
Hi All, I have what I consider to be an odd behavior on some of my AIX boxes. So far, on most of the AIX servers I have that are running Sybase,... -
Inheriting from System.Web.UI.WebControls.Table
I am trying to create an ASP.NET control by inheriting from Table. I would like to stop the Rows property from being displayed/persisted at... -
runtime error : FileNotFoundException on webservice call
Hello, I have got a security problem with my web service. When i deploy my WS on my production server, a FileNotFoundException is thrown. (see...



Reply With Quote

