调试SharePoint 2007代码
时间:2020-03-06 14:50:28 来源:igfitidea点击:
如何调试SharePoint 2007代码?由于SharePoint在远程服务器上运行,并且我正在Windows XP计算机上进行开发(将必需的.dll文件复制到了我的GAC中),因此我对寻找简单的调试方法没有多大的运气。断点不起作用,等等。
我想出的最好方法是在web.config文件中启用页面跟踪,在整个代码中写入跟踪消息,并在需要调试时访问trace.axd。
有没有人对调试有更好的建议?我想念什么吗?
解决方案
从安德鲁·康奈尔(Andrew Connell)关于该主题的博客文章中:
Attaching the debugger to GAC'd assemblies: "Why aren't my breakpoints being hit?!?!" Ever been there? Me too... what a PITA that is! What's going on? Well, the assemblies are in the GAC and the Visual Studio debugger can't see the debugging symbols (aka: *.pdb). Unless you've gone through the trouble of setting up a symbol store where all your PDBs are going, you'll need to put the debugging symbols in the same location as the assembly. The trick is finding the folder that contains your DLL in the GAC. The c:\windows\assembly folder is not a real folder, it's a virtual folder. To get to the REAL folder, do the following: Start ? Run %systemroot%\assembly\gac [ENTER] This will open the GAC folder. Now, poke around until you find a folder that looks like this (you might need to jump up one folder and dive into the MSIL folder): [assembly file name -.DLL extention][assembly version in format of > #.#.#.#]__[assembly public key token]. When you find that folder, open it up and you'll see your assembly. Copy the PDB file to that folder and then attach the debugger for some debugging joy!
我建议我们使用Sharepoint在Windows 2003服务器上进行开发。在远程服务器上调试很麻烦。
如果工作站上装有XP,则可以在具有VMWare或者Virtual PC的虚拟机中执行此操作。
虚拟机是唯一的方法。我们不想将整个机器专用于开发(除非我们有其他功能),而在生产服务器上进行开发只会带来麻烦。我更喜欢VMWare,但是还有其他一些也可以工作。
跟踪效果很好,因为常规调试实际上不是一种选择。
我要做的就是尝试在常规的asp.net网站上开发所有逻辑(不依赖SharePoint的东西),然后在经过测试后将其集成到SharePoint中。
希望这是有道理的。
我们在谈论开发Web部件吗?自定义页面?还有别的吗
最好的方法(甚至是Microsoft认可的一种方法)是将一台Windows 2003 Server和Sharepoint用作本地开发计算机。
另请参阅本主题。
不要将程序集放入GAC,将它们放在bin目录中,然后就可以使用VS远程调试器了。 Google创建.WSP文件进行分发。
这还有一个优点,即在编译后(构建后步骤)将新构建更轻松地复制到服务器上,并且还建议使用这种方法来提高安全性。