Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal, como estão?
espero que bem.
Estou com o seguinte problema.
Estou seguindo o modelo do Pet Shop 4.0 como base neste projeto.
Porém, quando tento instânciar um objeto, ele não consegue encontrar o assembly do mesmo:
Basicamente tenho na interface uma chamada ao BLL
Usuario u = new Usuario();
GridView1.DataSource = u.GetUsuarios();
GridView1.DataBind();
u = null;
Em seguida, no BLL tenho
private static readonly IUsuario dal = DataAccess.CreateUsuario(); Então no DataAccess tenho
private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
public static IUsuario CreateUsuario()
{
string className = path + ".Usuario";
return (IUsuario)Assembly.Load(path).CreateInstance(className);
}
Basicamente é isso.
Segui o que estava no projeto do Pet Shop.
Só que as coisas não estão muito claras pra mim.
Essa questáo de retornar um IUsuario criando um assembly est[a estranha.
Gostaria de agradecer ao Israé Aéce também, pela grande ajuda/paciência que tem tido comigo.
Se alguém tiver um tempinho pra me explicar essa parte aí, ficarei muito agradecido.
Abaixo segue o erro gerado.
Could not load file or assembly 'insidedotnet.MySQLDAL' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'insidedotnet.MySQLDAL' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 19: {
Line 20: string className = path + ".Usuario";
Line 21: return (IUsuario)Assembly.Load(path).CreateInstance(className);
Line 22: }
Line 23: }
Source File: E:\home\insidedotnet\DALFactory\DALFactory\DataAccess.cs Line: 21
Assembly Load Trace: The following information can be helpful to determine why the assembly 'insidedotnet.MySQLDAL' could not be loaded.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'insidedotnet.MySQLDAL' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +54
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
insidedotnet.DALFactory.DataAccess.CreateUsuario() in E:\home\insidedotnet\DALFactory\DALFactory\DataAccess.cs:21
insidedotnet.BLL.Usuario..cctor() in E:\home\insidedotnet\BLL\BLL\Usuario.cs:13
[TypeInitializationException: The type initializer for 'insidedotnet.BLL.Usuario' threw an exception.]
insidedotnet.BLL.Usuario..ctor() +0
_Default.Page_Load(Object sender, EventArgs e) in e:\home\insidedotnet\UI\Default.aspx.cs:16
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Muitíssimo obrigado pela atenção.
Abraços.
Carregando comentários...