Tôi có một dự án khung thực thể đang hoạt động tốt trên máy tính của tôi, nhưng sẽ bị ngắt khi chạy từ mạng. Thay đổi gần đây đối với dự án bao gồm việc thêm dll động LINQ (System.Linq.Dynamic)Ngoại lệ khởi tạo loại khung thực thể
Khi tôi gỡ lỗi nó từ mạng, VS báo cáo: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception
Trường hợp ngoại lệ bên trong là: "Không thể tải tập tin hoặc lắp ráp 'EntityFramework, Version = 4.4.0.0, Văn hóa = trung lập, PublicKeyToken = b77a5c561934e089' hoặc một trong các phụ thuộc của nó. Định nghĩa tệp kê khai của assembly không khớp với tham chiếu assembly (Ngoại lệ từ HRESULT: 0x80131040) ":" EntityFramework, Version = 4.4 .0.0, Văn hóa = trung lập, PublicKeyToken = b77a5c561934e089 "}
Tôi đã thử các thủ thuật thông thường: xóa thư mục packages
khỏi roo t của dự án, gỡ cài đặt và cài đặt lại từ bảng điều khiển của trình quản lý gói nhưng không có kết quả.
app.config của tôi:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="LGFinance.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="LGFinanceEntities" connectionString="metadata=res://*/Model.LGFinanceContext.csdl|res://*/Model.LGFinanceContext.ssdl|res://*/Model.LGFinanceContext.msl;provider=System.Data.SqlClient; provider connection string='data source=lightning;initial catalog=DLGDB;Integrated Security=true;Password=******;multipleactiveresultsets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<applicationSettings>
<LGFinance.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</LGFinance.Properties.Settings>
</applicationSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Ai đó có thể chỉ ra những gì tôi đã làm sai?
Khi bạn nói "nhưng đổ xuống khi chạy từ mạng", bạn có nghĩa là mã đang chạy trên máy khác. Nhiều khả năng bất cứ nơi nào bạn đang chạy mã không có khuôn khổ thực thể 5.0 dll.Kiểm tra thùng trên máy "từ xa" và xem nó có ở đó không. – cgotberg
Đúng, đến một máy khác. Nhưng tôi có tất cả các dll (và một vài xmls liên quan) nằm trong thư mục đó. Tất cả đã được làm việc cho đến ngày hôm nay, và chỉ có những thứ mới thực sự mà tôi có thể đổ lỗi cho nó là năng động linq – mcalex