Tag: visual studio 2010

使用Microsoft.Build.Evaluation发布数据库项目(.sqlproj)

我需要能够以编程方式发布SSDT项目。 我正在使用Microsoft.Build这样做,但找不到任何文档。 创建.dacpac似乎很简单,但是我如何发布到现有数据库或者至少发布到.sql文件。 我的想法是让它在我右键单击项目并选择发布时执行它所做的工作。 它应与选定的数据库进行比较并生成升级脚本。 这是我到目前为止创建的.dacpac: partial class DBDeploy { Project project; internal void publishChanges() { Console.WriteLine(“Building project ” + ProjectPath); Stopwatch sw = new Stopwatch(); sw.Start(); project = ProjectCollection.GlobalProjectCollection.LoadProject(ProjectPath); project.Build(); //at this point the .dacpac is built and put in the debug folder for the project sw.Stop(); Console.WriteLine(“Project build Complete. Total time: {0}”, sw.Elapsed.ToString()); […]

我得到了“缺少使用指令或汇编参考”,并且不知道出了什么问题

我正在尝试允许用户将数据输入到将添加到web.config文件的文本框中。 我已经将相关的行添加到web.config文件中但是当我使这个类出错时。 每当我尝试运行我的应用程序时,我一直在想你是否错过了using指令或程序集refenrence错误。 我已经看过其他时候这个问题已被问到,似乎无法弄清楚我哪里出错了。 问题是我对Visual Studio来说是一个非常新的东西,我只是留下了空白的答案。 下面是生成错误的类文件。 我希望我已经包含了你需要的一切来帮助我。 谢谢。 using System.Collections.Generic; using System.Linq; using System.Configuration; namespace WebConfigDemo { public class CompanyConfigSection : ConfigurationSection { [ConfigurationProperty(“”, IsRequired = true, IsDefaultCollection = true)] public CompanyConfigCollection Companies { get { return (CompanyConfigCollection)this[“”]; } set { this[“”] = value; } } } public class CompanyConfigElement : ConfigurationElement { [ConfigurationProperty(“id”, […]

T4模板错误:加载包含文件ef.utility.cs.ttinclude返回null或空字符串

我已经覆盖了控制器生成T4模板( ControllerWithContext.tt ),如此处所述。 我想利用在POCO模型生成器T4模板中使用的EF.utility.CS.ttinclude中的代码帮助程序实用程序。 因此,我Model.tt从我的Model.tt复制到我的ControllerWithContext.tt 。 但是,当我尝试添加控制器时,我收到错误消息 加载包含文件’EF.utility.CS.ttinclude’返回null或空字符串 根据MSDN文档 ,这个错误是因为包含的文件是空白的,显然不是因为它适用于Model.tt 我能看到的唯一区别是被覆盖的ControllerWithContext.tt没有定义自定义工具,而Model.tt将它设置为TextTemplatingFileGenerator 。 我的解决方法是将我需要的函数从ef.utility.cs.ttinclude到我的ControllerWithContext.tt ,它本身会抛出更多错误,但很容易解决。 如何在未定义自定义工具的情况下包含T4模板?

在T4模板中获取引用项目的路径?

我有一个解决方案,其中包含一些项目。 我想在我的一个测试项目中创建一些T4模板,以根据另一个项目中的代码生成测试。 测试项目有一个项目参考另一个项目。 我遇到的问题是我不知道如何获取我需要生成代码的edmx文件的文件路径。 示例(假装这是一个基于ASCII的解决方案资源管理器): MySolution.sln -> MyTests.csproj (C:\a\b\c\) —-> GeneratedTests.tt (C:\a\b\c\GeneratedTests.tt) -> MyDAL.csproj (C:\x\y\z\) —-> MyModel.edmx (C:\x\y\z\MyModel.edmx) 我的GeneratedTests.tt如何能够利用其项目引用获取MyModel.edmx的文件路径?

如何从Windows服务打印PDF文档

我有Windows服务,必须定期从服务器打印PDF文档。 我的function是 private void PrintFormPdfData(byte[] formPdfData) { string tempFile; tempFile = Path.GetTempFileName(); using (FileStream fs = new FileStream(tempFile, FileMode.Create)) { fs.Write(formPdfData, 0, formPdfData.Length); fs.Flush(); } string pdfArguments = string.Format(“/p /h\”{0}\””, tempFile); string pdfPrinterLocation = @”C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe”; ProcessStartInfo newProcess = new ProcessStartInfo(pdfPrinterLocation, pdfArguments); newProcess.CreateNoWindow = true; newProcess.RedirectStandardOutput = true; newProcess.UseShellExecute = false; newProcess.RedirectStandardError = […]

使用Visual C#2010 Express在C#项目中添加引用“SHDocVw”

我正在学习使用MS Visual Studio 2010和C#创建BHO的教程。 为了运行教程代码,我必须在我的项目中添加此引用: – 使用SHDocVw 但它在“添加引用”中的.NET或COM部分中不可用。 所以我想问一下,这个命名空间在Microsoft Visual C#2010 Express中不可用吗? 如果可用,如何添加它。 这是我的中途项目代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace IEPlugin { [ ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid(“FC4801A3-2BA9-11CF-A229-00AA003D7352”) ] public interface IObjectWithSite { [PreserveSig] int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site); [PreserveSig] int GetSite(ref Guid guid, out IntPtr ppvSite); } [ ComVisible(true), Guid(“2159CB25-EF9A-54C1-B43C-E30D1A4A8277”), ClassInterface(ClassInterfaceType.None) ] public class BHO […]

调试在启动时崩溃的C#可执行文件

我正在尝试远程调试C#程序。 连接到主机是没有问题的,我可以看到该机器上运行的所有进程,并可以连接到msvsmon.exe 。 但是,我想调试的程序在启动时立即崩溃,让我没有时间依赖它。 通过远程位置启动有问题的调试可执行文件也不起作用。 如何在崩溃前附加调试器?

x64中的Visual Studio设计器不起作用

在Visual Studio 2010 64位中,我无法设计表单。 我一直收到这个警告(和错误): Warning 18 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: MainForm — The base class ‘Blah’ could not be loaded. Ensure the assembly has been referenced and that all projects […]

在Visual C#2010中获取DTE2对象的引用

我想获得对当前解决方案的引用,在Visual Studio 2010中使用带有C#的DTE2对象。 我首先尝试了以下代码: var dte = Marshal.GetActiveObject(“VisualStudio.DTE.10.0”) as EnvDTE80.DTE2; 但是当我打开2个解决方案,并且这个代码在第一个解决方案中时,我得不到对当前解决方案的引用,而是对我加载的最后一个解决方案的引用。 我需要当前的解决方案…… 在互联网上搜索,我发现以下解决方案如何从VSPackage获取当前的解决方案目录? : // Get an instance of the currently running Visual Studio IDE DTE dte = (DTE)GetService(typeof(DTE)); 但是当我使用它时,我的dte对象总是为NULL。 那么如何使用C#on .net framework 4.0获取VS2010中当前的解决方案对象?

为什么System.Diagnostics.Debug.WriteLine在Visual Studio 2010 C#中不起作用?

我的代码中有以下行: System.Diagnostics.Debug.WriteLine(“Title:” + title + “title[top]: ” + title[top] + “title[sub]: ” + title[sub]); 当我调试时,我看到它会转到这一行,但当我在Visual Studio 2010中查看输出窗口时,即使它显示“Debug”并且我使用“debug> run”运行,我也看不到任何内容。 为什么?