草庐IT

initialize-assemblies-using-preap

全部标签

c# - 我们什么时候不应该创建 Assembly 的强名称? "strong named assembly"的缺点是什么?

我有一个项目,即library.exe。在此我引用了一个程序集(logging.dllver1.0.3.0)并且我给这个程序集起了一个强名称。现在假设我更改了logging.dll中的一个方法并制作了版本1.0.4.0。现在当我用这个新的DLL复制/替换旧的DLL时,我得到了一个异常。我知道异常是因为我更改了DLL的版本号。因为它是一个强名称DLL,除非我重建library.exe,否则不允许使用它。上面的故事我想说的是仅当我们必须将其添加到GAC时,才对程序集使用强名称。如果我们有一个应用程序,其中单个程序集需要更新,请不要使用强命名程序集。我对第1点和第2点的看法是否正确?什么时候

c# - "Data Source cannot be empty. Use :memory: to open an in-memory database"是什么意思?

我最近将我的SQLServer数据库转换为SQLite数据库。但是当我尝试使用.Open()打开我的SQLite时,它​​抛出了这个错误:DataSourcecannotbeempty.Use:memory:toopenanin-memorydatabase编辑:添加连接字符串:ConnectionString=@"DataSource=D:\XXX.db;Version=3";connection=newSQLiteConnection(connectionString);connection.Open();为什么我会得到这个?我将相同的SQLServer数据库转换为SQLCE和my

c# - Using block 中的异步

我在C#中有以下异步函数:privateasyncTaskCallDatabaseAsync(Func>execAsync){using(varconnection=newSqlConnection(_connectionString)){connection.Open();returnawaitexecAsync(connection);}}它允许执行任何异步函数execAsync,该函数将SQL连接作为参数并使用它来进行数据库调用,方法是提供连接对象并确保其正确关闭。然后从WebApiController中的操作调用此函数,如下所示:publicasyncTaskMyAction(

c# - 属性规范中奇怪的歧义(两个 using 指令)

背景在attributespecification,有时有两种有效的方法来编写应用的属性。例如,如果属性类的名称为HorseAttribute,您可以将该属性应用为[HorseAttribute]或只是[Horse]。歧义可以用@解决,例如[@Horse]。以下是一个有效的程序:usingSystem;usingAlpha;usingBeta;namespaceN{[Horse]classC{}}namespaceAlpha{//validnon-abstractattributetypewithaccessibleconstructorclassHorseAttribute:Attr

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - 未找到类型或命名空间 "are you missing assembly reference"而所有引用都正确

我正在尝试使用MSBuildWorkspaceclass.我的项目中有所有程序集引用。当我在对象浏览器中打开引用时,我看到了namespace和我尝试使用的类。但是在我接下来的using语句中,使用Microsoft.CodeAnalysis.MSBuild我得到一个Thetypeornamespacename'MSBuild'doesnotexistinthenamespace'Microsoft.CodeAnalysis'(areyoumissinganassemblyreference?)但有趣的是,语法高亮器识别类型名称,这是编译器的提示这是构建日志1>c:\windows\M

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - LINQ 如何在 using 语句中延迟执行

假设我有以下内容:privateIEnumerableMyFunc(parametera){using(MyDataContextdc=newMyDataContext){returndc.tablename.Select(row=>row.parameter==a);}}privatevoidUsingFunc(){varresult=MyFunc(newa());foreach(varrowinresult){//Dosomething}}根据文档,linq执行将推迟到我实际枚举结果时,该结果出现在foreach的行中。但是,using语句应强制在调用MyFunct()结束时可靠地

c# - 混淆使用 "using"语句 C#

根据MSDNLibraryusingStatement(C#Reference)Definesascope,outsideofwhichanobjectorobjectswillbedisposed.但是我得到了一些用户在这里发布的这段代码,我对此感到困惑:(请参阅我对代码的评论)using(OleDBConnectionconnection=newOleDBConnection(connectiongString)){if(connection.State!=ConnectionState.Open)connection.Open();stringsql="INSERTINTOStu

c# - 尝试运行项目 :The module was expected to contain an assembly manifest 时出错

当我尝试运行该项目时,它显示:Errorwhiletryingtorunproject:couldnotloadfileorassembly'Project.exe'oroneofitsdependencies.Themodulewasexpectedtocontainanassemblymanifest.当我从调试文件夹运行exe时,出现了这个错误:applicationunabletostartcorrectly(0xc000007b)我也重新安装了VisualStudio,但它似乎不起作用! 最佳答案 Themodulewas