如何通过VB.NET部署修复LINQ依赖问题?

时间:2021-11-24 12:47:34

I have a program that contains .dbml files. I created this file with Server Explorer.

我有一个包含.dbml文件的程序。我用Server Explorer创建了这个文件。

I want to execute this program on other computers but I seem to be having issues with dependencies because I use LINQ.

我想在其他计算机上执行此程序,但我似乎遇到了依赖项问题,因为我使用LINQ。

How can I fix this?

我怎样才能解决这个问题?

2 个解决方案

#1


Can you be more specific? What errors are you encountering? Did you use SQL Passwords or Network authentication? Do your users have network accounts added to SQL? Is this a permission based error?

你可以说得更详细点吗?你遇到了什么错误?您使用的是SQL密码还是网络身份验证?您的用户是否已将网络帐户添加到SQL?这是基于权限的错误吗?

Just one other possibility: Your users should have .NET 3.51 installed on their systems or they won't get the best possible Linq support. They might not have the Linq assemblies at all.

另一种可能性:您的用户应该在他们的系统上安装.NET 3.51,否则他们将无法获得最佳的Linq支持。他们可能根本没有Linq组件。

#2


Yeah, we need more info, but I'm guessing you're having problems with the ConnectionString? as in, there's a connection string in your DBML designer file, and it doesn't match your production DB connection string?

是的,我们需要更多信息,但我猜你在使用ConnectionString时遇到了问题?在,您的DBML设计器文件中有一个连接字符串,它与您的生产数据库连接字符串不匹配?

If this is the case, then perhaps write a class that handles all instantiations of your DataContext in your code.

如果是这种情况,那么可能编写一个类来处理代码中DataContext的所有实例化。

Then, within that class, whenever a new datacontext is created, you override the DBML connectionstring with your current connectionstring, probably from your web.config. this ensures your LINQ stuff is always connected to the correct DB during runtime.

然后,在该类中,每当创建新的datacontext时,您可以使用当前的连接字符串覆盖DBML连接字符串,可能来自您的web.config。这可确保您的LINQ内容始终在运行时连接到正确的DB。

Perhaps something like this (the property names might differ):

也许是这样的(属性名称可能不同):

Public Shared Function GetNewContext() As YourDataContext
   Dim dContext As YourDataContext

   dContext = New YourDataContext()
   dContext.Connection.ConnectionString = MyConnectionStringFromTheWebConfig()

   Return dContext

End Function

#1


Can you be more specific? What errors are you encountering? Did you use SQL Passwords or Network authentication? Do your users have network accounts added to SQL? Is this a permission based error?

你可以说得更详细点吗?你遇到了什么错误?您使用的是SQL密码还是网络身份验证?您的用户是否已将网络帐户添加到SQL?这是基于权限的错误吗?

Just one other possibility: Your users should have .NET 3.51 installed on their systems or they won't get the best possible Linq support. They might not have the Linq assemblies at all.

另一种可能性:您的用户应该在他们的系统上安装.NET 3.51,否则他们将无法获得最佳的Linq支持。他们可能根本没有Linq组件。

#2


Yeah, we need more info, but I'm guessing you're having problems with the ConnectionString? as in, there's a connection string in your DBML designer file, and it doesn't match your production DB connection string?

是的,我们需要更多信息,但我猜你在使用ConnectionString时遇到了问题?在,您的DBML设计器文件中有一个连接字符串,它与您的生产数据库连接字符串不匹配?

If this is the case, then perhaps write a class that handles all instantiations of your DataContext in your code.

如果是这种情况,那么可能编写一个类来处理代码中DataContext的所有实例化。

Then, within that class, whenever a new datacontext is created, you override the DBML connectionstring with your current connectionstring, probably from your web.config. this ensures your LINQ stuff is always connected to the correct DB during runtime.

然后,在该类中,每当创建新的datacontext时,您可以使用当前的连接字符串覆盖DBML连接字符串,可能来自您的web.config。这可确保您的LINQ内容始终在运行时连接到正确的DB。

Perhaps something like this (the property names might differ):

也许是这样的(属性名称可能不同):

Public Shared Function GetNewContext() As YourDataContext
   Dim dContext As YourDataContext

   dContext = New YourDataContext()
   dContext.Connection.ConnectionString = MyConnectionStringFromTheWebConfig()

   Return dContext

End Function