MonoDevelop 上 ASP.NET Web 服务中的 Dblinq 引用导致 xsp2 出现故障

发布于 2024-09-26 15:23:24 字数 6015 浏览 2 评论 0原文

我正在尝试在简单的 ASP.NET Web 中使用 sqlite 提供程序尝试 DBLinq 服务。我也在使用 MonoDevelop 2.4 和 Mono 2.6.7,该项目 在 monodevelop 中引用了 DbLinq.dll,默认情况下设置为 本地副本。我可以很好地编译网络服务。当我尝试时 从 Monodevelop 运行它或从命令行使用 xsp2,xsp2 失败并出现一些错误(见下文)。如果我取消选中本地 复制 DBLinq.dll 引用,xsp2 将执行,但 Linq 部分 的代码不起作用。对于 MySQL 提供商来说也是如此。我认为问题是当引用 DbLinq 并在本地复制时,它也会复制依赖项 程序集,其中一个程序集导致 xsp2 阻塞。

有人遇到过这种情况吗?我该如何解决这个问题或者问题是什么 解决方法?非常感谢任何帮助。下面是示例 后面的 asmx 代码中的 webservice 方法的片段。

[Web方法]
公共字符串 getrecord() {

string txt = string.Empty; 

使用( DataContext 上下文 = 
   新的 DataContext("DbLinqProvider=Sqlite; 数据源=openemr.db")) 
    {
            var addrtbl = context.GetTable<地址>(); 
            var addr = 来自 addrtbl 中的 a 
                    选择一个; 
            foreach( var i in addr ) 
            { 
                    txt += i.City ; 
                    txt+=“;”; 
            } 
    } 

返回txt;
}

,这可能不是实现数据访问和 需要将关注点分开。但出于测试目的,这 至少应该有效。

这是我运行 xsp2 时遇到的错误。正如我上面所说,其中之一 DbLinq 引用并本地复制的依赖程序集是 导致这种情况发生。我的问题是如何最好地解决这个问题 作品?

user@ubuntu:~/Projects/WebService/WebService$ xsp2 --address 127.0.0.1 --port 8889

** (/usr/lib/mono/2.0/xsp2.exe:2566): 警告 **: 缺少方法 System.Web.Configuration.WebConfigurationManager::get_AppSettings() 中 程序集 /usr/lib/mono/gac/System.Web/2.0.0.0_b03f5f7f11d50a3a/ System.Web.dll,在程序集 /usr/lib/mono/gac/Mono.Web/ 中引用 2.0.0.0_0738eb9f132ed756/Mono.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566):警告 **:缺少方法 System.Configuration.ConfigurationProperty::.ctor(字符串、类型、对象、TypeConverter、ConfigurationValidatorBase、ConfigurationPropertyOptions) 在程序集中/home/ellory/Projects/WebService/WebService/bin/ System.Configuration.dll,在程序集 /usr/lib/mono/gac/ 中引用 System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566):警告 **:缺少方法 System.Configuration.ConfigurationProperty::.ctor(字符串、类型、对象、TypeConverter、ConfigurationValidatorBase、ConfigurationPropertyOptions) 在程序集中/home/ellory/Projects/WebService/WebService/bin/ System.Configuration.dll,在程序集 /usr/lib/mono/gac/ 中引用 System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566):警告 **:缺少方法 System.Configuration.ConfigurationProperty::.ctor(字符串、类型、对象、TypeConverter、ConfigurationValidatorBase、ConfigurationPropertyOptions) 在程序集中/home/ellory/Projects/WebService/WebService/bin/ System.Configuration.dll,在程序集 /usr/lib/mono/gac/ 中引用 System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566):警告 **:缺少方法 System.Configuration.ConfigurationProperty::.ctor(字符串、类型、对象、TypeConverter、ConfigurationValidatorBase、ConfigurationPropertyOptions) 在程序集中/home/ellory/Projects/WebService/WebService/bin/ System.Configuration.dll,在程序集 /usr/lib/mono/gac/ 中引用 System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll 处理异常类型TargetInitationException 消息是调用目标已引发异常。 IsTerminate 设置为 True System.Reflection.TargetInitationException:已引发异常 通过调用的目标。

服务器堆栈跟踪: 在 System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr、System.Reflection.Binder 绑定器、 System.Object[] 参数、System.Globalization.CultureInfo 文化) [0x00000] 在:0 在 System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder 绑定器,System.Object[] 参数, System.Globalization.CultureInfo 文化)[0x00000] 中:0 在 System.Reflection.ConstructorInfo.Invoke (System.Object[] 参数)[0x00000] in :0 在 System.Activator.CreateInstance (System.Type 类型,布尔值 非公共)[0x00000] 在:0 在System.Configuration.ConfigInfo.CreateInstance()[0x00000]中 :0 在System.Configuration.SectionInfo.CreateInstance()[0x00000]中 :0 在 System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo 配置,布尔值 createDefaultInstance) [0x00000] 在:0 在 System.Configuration.ConfigurationSectionCollection.get_Item (System.String 名称) [0x00000] in :0 在 System.Configuration.Configuration.GetSection (System.String 路径)[0x00000] 中:0 在 System.Web.Configuration.WebConfigurationManager.GetSection (System.String 节名、System.String 路径、System.Web.HttpContext 上下文)[0x00000] in :0 在 System.Web.Configuration.WebConfigurationManager.GetSection (System.String 节名,System.String 路径) [0x00000] in :0 在 System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection (System.String 节名) [0x00000] in :0 在 System.Web.Hosting.ApplicationHost.SetHostingEnvironment () [0x00000] 在:0 在 System.AppDomain.DoCallBack (System.CrossAppDomainDelegate callBackDelegate) [0x00000] 在:0 在(包装器远程调用带检查)System.AppDomain:DoCallBack (系统.CrossAppDomainDelegate) 在(包装器xdomain-dispatch)System.AppDomain:DoCallBack (object,byte[]&,byte[]&)

在 [0] 重新抛出异常: ---> System.TypeInitializationException:抛出异常 的类型初始值设定项 System.Web.Configuration.HostingEnvironmentSection ---> System.MissingMethodException:找不到方法: 'System.Configuration.ConfigurationProperty..ctor'。 --- 内部异常堆栈跟踪结束 --- at(包装器管理到本机) System.Reflection.MonoCMethod:InternalInvoke (对象,对象[],System.Exception&) 在 System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr、System.Reflection.Binder 绑定器、 System.Object[] 参数、System.Globalization.CultureInfo 文化) [0x00000] 在:0 --- 内部异常堆栈跟踪结束 --- 在(包装器xdomain-invoke)System.AppDomain:DoCallBack (系统.CrossAppDomainDelegate) 在(包装器远程调用带检查)System.AppDomain:DoCallBack (系统.CrossAppDomainDelegate) 在 System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type 主机类型、System.String virtualDir、System.String 物理目录) [0x00000] in :0 在 Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer 服务器、Mono.WebServer.WebSource webSource) [0x00000] 在 :0 在 Mono.WebServer.XSP.Server.RealMain (System.String[] args, 布尔值 root, IApplicationHost ext_apphost, 布尔安静) [0x00000] 中 :0 at(包装器远程调用带检查) Mono.WebServer.XSP.Server:RealMain (字符串[],布尔,Mono.WebServer.IApplicationHost,布尔) 在 Mono.WebServer.XSP.Server.Main (System.String[] args) [0x00000] 于:0

I am trying to try DBLinq with the sqlite provider inside a simple ASP.NET web
service. I am also using MonoDevelop 2.4 and Mono 2.6.7, The project
in monodevelop references the DbLinq.dll which by default is set to be
Local Copy. I can compile the webservice just fine. By when I try to
run it from Monodevelop or using the xsp2 from the command line, xsp2
fails with a number of errors (see below). If I unchecked the Local
Copy for the DBLinq.dll reference, xsp2 will execute but the Linq portion
of the code does not work. This is also true for the MySQL provider. I think the problem is the when DbLinq is referenced and be locally copied, it also copies the dependent
assemblies and one of the assembly is causing xsp2 to choke.

Has anyone encountered this? How can I fix the problem or what is the
workaround? Any help is very much appreciated. Below is the sample
snippet of the webservice method in the asmx code behind.

[WebMethod]
public string getrecord()
{

string txt = string.Empty; 

using( DataContext context = 
   new DataContext("DbLinqProvider=Sqlite; Data Source=openemr.db")) 
    {
            var addrtbl = context.GetTable<Addresses>(); 
            var addr = from a in addrtbl 
                    select a; 
            foreach( var i in addr) 
            { 
                    txt += i.City ; 
                    txt += "; "; 
            } 
    } 

return txt;
}

Of course, this might not be a good way to implement data access and
will need to separate the concerns. But for testing purposes, this
should at least work.

Here is the error I get when I run xsp2. As I said above, one of the
dependent assemblies that DbLinq references and copied locally is
causing this to happen. My question is how do I best fix this so it
works?

user@ubuntu:~/Projects/WebService/WebService$ xsp2 --address
127.0.0.1 --port 8889

** (/usr/lib/mono/2.0/xsp2.exe:2566): WARNING **: Missing method
System.Web.Configuration.WebConfigurationManager::get_AppSettings() in
assembly /usr/lib/mono/gac/System.Web/2.0.0.0_b03f5f7f11d50a3a/
System.Web.dll, referenced in assembly /usr/lib/mono/gac/Mono.Web/
2.0.0.0
_0738eb9f132ed756/Mono.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566): WARNING **: Missing method
System.Configuration.ConfigurationProperty::.ctor(string,Type,object,TypeCo­nverter,ConfigurationValidatorBase,ConfigurationPropertyOptions)
in assembly /home/ellory/Projects/WebService/WebService/bin/
System.Configuration.dll, referenced in assembly /usr/lib/mono/gac/
System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566): WARNING **: Missing method
System.Configuration.ConfigurationProperty::.ctor(string,Type,object,TypeCo­nverter,ConfigurationValidatorBase,ConfigurationPropertyOptions)
in assembly /home/ellory/Projects/WebService/WebService/bin/
System.Configuration.dll, referenced in assembly /usr/lib/mono/gac/
System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566): WARNING **: Missing method
System.Configuration.ConfigurationProperty::.ctor(string,Type,object,TypeCo­nverter,ConfigurationValidatorBase,ConfigurationPropertyOptions)
in assembly /home/ellory/Projects/WebService/WebService/bin/
System.Configuration.dll, referenced in assembly /usr/lib/mono/gac/
System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

** (/usr/lib/mono/2.0/xsp2.exe:2566): WARNING **: Missing method
System.Configuration.ConfigurationProperty::.ctor(string,Type,object,TypeCo­nverter,ConfigurationValidatorBase,ConfigurationPropertyOptions)
in assembly /home/ellory/Projects/WebService/WebService/bin/
System.Configuration.dll, referenced in assembly /usr/lib/mono/gac/
System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
Handling exception type TargetInvocationException
Message is Exception has been thrown by the target of an invocation.
IsTerminating is set to True
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation.

Server stack trace:
at System.Reflection.MonoCMethod.Invoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00000] in :0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.ConstructorInfo.Invoke (System.Object[]
parameters) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type, Boolean
nonPublic) [0x00000] in :0
at System.Configuration.ConfigInfo.CreateInstance () [0x00000] in
:0
at System.Configuration.SectionInfo.CreateInstance () [0x00000] in
:0
at System.Configuration.Configuration.GetSectionInstance
(System.Configuration.SectionInfo config, Boolean
createDefaultInstance) [0x00000] in :0
at System.Configuration.ConfigurationSectionCollection.get_Item
(System.String name) [0x00000] in :0
at System.Configuration.Configuration.GetSection (System.String
path) [0x00000] in :0
at System.Web.Configuration.WebConfigurationManager.GetSection
(System.String sectionName, System.String path, System.Web.HttpContext
context) [0x00000] in :0
at System.Web.Configuration.WebConfigurationManager.GetSection
(System.String sectionName, System.String path) [0x00000] in :0
at
System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection
(System.String sectionName) [0x00000] in :0
at System.Web.Hosting.ApplicationHost.SetHostingEnvironment ()
[0x00000] in :0
at System.AppDomain.DoCallBack (System.CrossAppDomainDelegate
callBackDelegate) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack
(System.CrossAppDomainDelegate)
at (wrapper xdomain-dispatch) System.AppDomain:DoCallBack
(object,byte[]&,byte[]&)

Exception rethrown at [0]:
---> System.TypeInitializationException: An exception was thrown by
the type initializer for
System.Web.Configuration.HostingEnvironmentSection --->
System.MissingMethodException: Method not found:
'System.Configuration.ConfigurationProperty..ctor'.
--- End of inner exception stack trace ---
at (wrapper managed-to-native)
System.Reflection.MonoCMethod:InternalInvoke
(object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00000] in :0
--- End of inner exception stack trace ---
at (wrapper xdomain-invoke) System.AppDomain:DoCallBack
(System.CrossAppDomainDelegate)
at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack
(System.CrossAppDomainDelegate)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost
(System.Type hostType, System.String virtualDir, System.String
physicalDir) [0x00000] in :0
at Mono.WebServer.VPathToHost.CreateHost
(Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource
webSource) [0x00000] in :0
at Mono.WebServer.XSP.Server.RealMain (System.String[] args, Boolean
root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in
:0
at (wrapper remoting-invoke-with-check)
Mono.WebServer.XSP.Server:RealMain
(string[],bool,Mono.WebServer.IApplicationHost,bool)
at Mono.WebServer.XSP.Server.Main (System.String[] args) [0x00000]
in :0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2024-10-03 15:23:24

DbLinq 是 Mono 上 LINQ to SQL 和 System.Data.Linq 命名空间的基础。因此您不必部署/引用 DbLinq 程序集。当您使用 Mono 时,请忘记 DbLinq。

代码的 LINQ 部分失败,因为数据上下文未正确初始化。
您应该这样做:

var context = new DataContext("DbLinqProvider=Sqlite; DbLinqConnectionType=Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756; Data Source=openemr.db");
// or
var context = new DataContext(new SqliteConnection("DbLinqProvider=Sqlite; Data Source=openemr.db"));

请参阅:http://www.mono-project.com/Release_Notes_Mono_2.6 #LINQ_to_SQL

DbLinq is the foundation of LINQ to SQL and System.Data.Linq namespace on Mono. So you don't have to deploy/reference the DbLinq assemblies. Forget about DbLinq when you're using Mono.

The LINQ portion of your code fail because the data context is not properly initialized.
You should do :

var context = new DataContext("DbLinqProvider=Sqlite; DbLinqConnectionType=Mono.Data.Sqlite.SqliteConnection, Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756; Data Source=openemr.db");
// or
var context = new DataContext(new SqliteConnection("DbLinqProvider=Sqlite; Data Source=openemr.db"));

See: http://www.mono-project.com/Release_Notes_Mono_2.6#LINQ_to_SQL

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文