在运行时动态加载程序集依赖关系的问题(Problems loading assembly dependencies dynamically at run-time)
让我试着解释我的问题。 我目前正在尝试开发一个用.Net编写的小型“插件框架”(主要用于实验)。 所以这个想法是通过在主应用程序的特定文件夹“插件”中部署dll来创建一个可以添加“插件”的主应用程序。 一切正常,插件正确实例化,但现在我面临一个问题。 我现在部署了一个插件“X”,它使用了额外的第三方插件,所以现在我遇到了这样的问题:在运行时找不到“X”所需的其他第三方插件。 我的想法现在是添加一个额外的目录“依赖关系”,我也部署了所有需要的插件。
所以我的第一个问题是:如何将程序集加载到应用程序域中(假定我知道它们的路径),它们可以被我的应用程序使用?
我试图通过做类似的事情来解决这个问题:
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { //find the path to the assembly and then load and return it by //return Assembly.Load("pathToDependencies/failedAssembly.dll"); }
问题是这个事件处理程序现在被激活并在args变量中使用“Presentation.Zune.dll”(我正在使用WPF应用程序)。 好像那个程序集加载失败但实际问题是另一个dll。
有人可以建议我一个更好的方法来解决我的问题吗? 我希望我能够充分解释我的情况,否则只是要求进一步澄清。
谢谢,Juri
let me try to explain my problem. I'm currently trying to develop a small "plugin-framework" written in .Net (mainly for experimenting a bit). So the idea is to have a main application to which "plugins" can be added by deploying dlls in a specific folder "plugins" of the main application. Everything works fine, the plugins are instantiated properly, however now I'm facing a problem. I have deployed now a plugin "X" that uses additional 3rd-party plugins and so now I have the problem that these additional 3rd-party plugins required by "X" are not found at run-time. My idea is therefore now to add an additional directory "dependencies" where I also deploy all of the needed plugins.
So my first question: How can I load the assemblies into the application domain (given that I know the path to them) s.t. they can be used by my application?
I tried to approach that by doing something like:
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { //find the path to the assembly and then load and return it by //return Assembly.Load("pathToDependencies/failedAssembly.dll"); }
The problem is that this event-handler now gets activated having the "Presentation.Zune.dll" in the args variable (I'm using a WPF app). It seems as if that assembly failed loading but the actual problem is another dll.
Can someone suggest me a better way to solve my problem? I hope that I was able to explain my situation sufficiently, otherwise just ask for further clarification.
Thanks, Juri
原文:https://stackoverflow.com/questions/592681
最满意答案
只要没有错误,
FIRAuth.auth()?.createUserWithEmail
将立即创建用户,那么就不需要// Create Firebase User let userData = ["provider" : "email", "password": password!] DataService.ds.createFirebaseUser(user!.uid, user: userData) print("firebase user created!") self.loginUser()
检查您的Firebase控制台以查看用户是否已创建
As long as there is no error,
FIRAuth.auth()?.createUserWithEmail
will create the user immediately, there would be no need for// Create Firebase User let userData = ["provider" : "email", "password": password!] DataService.ds.createFirebaseUser(user!.uid, user: userData) print("firebase user created!") self.loginUser()
check your firebase console to see if users have been created
相关问答
更多-
尝试使用: try! FIRAuth.auth()!.signOut() 这是我在IBAction中的代码,它工作得很好: try! FIRAuth.auth()!.signOut() if let storyboard = self.storyboard { let vc = storyboard.instantiateViewControllerWithIdentifier("firstNavigationController") as! UINavigationController ...
-
从我从JSON响应中可以看到, parseJSON["status"]是HTTP statusCode,它是一个数字状态代码。 200是成功,400是坏请求,404是未找到,500是错误。 您可以从字典中读取消息,也可以根据PHP代码的工作方式将状态转换为Integer,并在状态为200时仅进行segue。对于任何其他状态代码,您可能希望向用户显示消息。 这取决于您是否故意根据结果返回状态代码,例如,状态代码401 未经授权 。 正确使用状态代码比比较字符串要可靠得多。 编辑: import Foundat ...
-
Firebase注册Swift(Firebase sign up with Swift)[2022-05-01]
只要没有错误, FIRAuth.auth()?.createUserWithEmail将立即创建用户,那么就不需要 // Create Firebase User let userData = ["provider" : "email", "password": password!] DataService.ds.createFirebaseUser(user!.uid, user: userData) print("firebase user created!") self.loginUser() 检查 ... -
我认为在应用程序中(_ application:UIApplication,open url:URL,sourceApplication:String?,annotation:Any) - > Bool,你需要得到GIDSignIn.sharedInstance()。handle的结果(url,sourceApplication:sourceApplication,annotation) :注释)并将其与FB一起返回。 所以它应该是这样的: return handled || GIDSignIn.share ...
-
您可以在旧网站上登录。 但是,似乎firebase 在可预见的未来强制要求谷歌帐户。 You can login here on the older site. However, it seems like firebase is making google accounts mandatory for the foreseeable future.
-
您通常希望在Swift代码和服务器端安全规则中添加验证,但原因各不相同。 您必须在服务器上进行验证,因为它是恶意客户端无法绕过的唯一验证类型。 此验证是您防止错误数据的最后一道防线。 您可能还想验证客户端上的数据。 这更像是为您的用户提供的服务:如果您在客户端上进行验证,则可以根据您的规则向他们提供有关其数据是否有效的早期(通常更好)消息。 You'll typically want to add validation both in your Swift code and in your server-s ...
-
Firebase搭配Swift(Firebase with Swift)[2022-04-02]
我设法让它运作起来。 事实证明,firebase网站上的视频解释了哪些依赖项已经过时了。 我在页面下面进一步阅读,看到firebase实际上需要两个我缺少的依赖项。 添加libc++.dylib , libiucore.dylib , CFNetwork.framework , Security.framework和SystemConfiguration.framework一切正常。 I managed to get it working. It turns out that the video on th ... -
可能有一些事情出错了, 您没有安装Firebase / auth pod。 firapp没有完成自我配置,你正在调用一个firebase函数。 我认为最有可能是第一个。 在这种情况下,打开podfile并添加pod'Firebase / Auth' 这个问题是通过不安装所有的Firebase功能/ pod解决的。 There may be a couple of things that went wrong, You did not install firebase/auth pod. The firapp ...
-
我的逻辑如下有效。 另外,请确保您没有在storyboard Segues并忘记的任何Segues 。 //this checks 3 fields that they are filled and not empty if passwordTextField.text == "" || emailTxt.text == "" || usernameTextField.text == ""{ simpleAlert(mess: "You must fill all fie ...
-
请不要使用电子邮件地址作为密钥。 电子邮件地址是动态的,可能会发生变化(如果用户想要更改它们),如果他们这样做,您将手上一团糟,因为直接使用该电子邮件的每个节点都将被删除并重新创建。 最佳做法是将密钥与其包含的数据解除关联。 这是要使用的结构 emails -Yiaisjpa90is email: "dude@test.com" -Yijs9a9js09a email: "thing@test.com" 然后,您只需在电子邮件节点中查询您要查找的电子邮件,并相应处理(如果存在)。 ...