I tried to follow up Ram's suggestion and exported data in a GridView to a word documents by following code snippet:

 

代码

 

After building the project and try to view it in browser, however, the browser just told me the following message when clicking the Export data button:
 Error Message

 

 

 

 

 

 

 

 

 

 

 

 

After a quick search, I found: http://rstew.blogspot.com/2007/10/gridview-must-be-placed-inside-form-tag.html, great post, override the VerifyRenderingInServerForm method, the process works happily!

public override void VerifyRenderingInServerForm(Control control)

{

      return;

}

 

posted @ 2009-11-27 19:02 Roahn Luo 阅读(199) 评论(0) 编辑

在64位Vista机器上调用一个native的.dll 文件时, 经常会报这个错误:
 

这是因为我们的Configuration Manager没有配置好: 如果我们在64位机器上使用AnyCPU的配置,我们的程序可以加载anycpu.dll 和x64.dll, 但是, 如果我们试图加载x86.dll就会出现BadImageFormatException的错误。同样地, 如果我们使用的是x86的选项, 我们也会收到同样的消息--如果我们试图加载x64.dll的话。

在我的机器上, 由于native dll 文件是用Win32的platform来build的,所以我把manage的项目改到x86选项下(如果没有,我们可以新建一个)重新build后, 没有出现BadImageFormatException的对话框了, 不过我测试了一下, 这个方法对Windows Service的程序不太管用。

posted @ 2009-11-27 12:51 Roahn Luo 阅读(104) 评论(0) 编辑

I encountered a problem in Microsoft MSDN Visual Studio Debugger forum, the original thread is:
http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/64a02264-2beb-4794-913b-a96ec0ea0c58

I have to say, it’s an amazing thing to reproduce what has happened to the customer. However, there are a lot learned by the process
during the reproduce.

ISSUE REPRODUCE
=====================

Here is the process that I reproduce the problem, we could learn how to access ActiveX Object controls (an MSFlexGrid control in VB6 in this case.) from within.

  1. Find the original trouble maker – MSFlexGrid control
Open Microsoft Visual Basic 6.0, and create a new standard project, right click the toolbox and choose Components... to open the Components dialog box, here,
we find the “Microsoft FlexGrid Control 6.0 (SP6), and its location is D:"Windows"System32"MSFlxGrd.ocx (just the path on my box, not needed the same.)
If you did not install Visual Basic 6.0, the file MSFlxGrd.ocx could be download anywhere in the Internet.

    2. Since the FlexGrid control is a COM component, however, Windows Forms Applications only host Windows Forms controls – that is, classes that are derived
from Control. We need to convert type defined in a COM type library for an ActiveX control into a Windows Forms control.
We need a tool called Aximp.exe[http://msdn.microsoft.com/en-us/library/8ccdh774(VS.80).aspx] to complete this job.

    3. Convertion.
Open Visual Studio 2008 Command Prompt and input aximp [path]"MSFlxGrd.ocx. After this step, we could see two files were generated under the folder
C:"Program Files"Microsoft Visual Studio 9.0"VC, one is named MSFlexGridLib.dll and another is named AxMSFlexGridLib.dll

    4. Using the ActiveX control
Now, Open Visual Studio 2008 and create a new Windows Forms Application, Open the Toolbox and right click the blank area and choose “Choose Items...”
(this will open the “Choose Toolbox Items” dialog box). Click COM Components tab then, and find “Microsoft FlexGrid control, version 6.0” checkbox. Check it without
any doubt and then click OK button. A moment later, an icon something looks like: will appear on the Toolbox,
drag and drop it to the new form we just created.

    5. Problem reproduce
paste the code snippet in our project, set a breakpoint in a right place, then debug..... I’ve to say, the first turn of the loop has been executed successfully,
and when executing the second turn of the for loop, the exception was thrown:

ROOT CAUSE:
===============

A simple word to describe the cause is that the index of the Col is out of range of the Cols property of the ActiveX control.

Initially, we could set properties of the ActiveX control through the ActiveX –Properties, like this:

we could see from the above screen shot that the Cols is 5, if we write managed code like:for( int i=0; i<10; i++)
{
       this.axMSFlexGrd.Col = i;
       this.axMSFlexGrid.Text = “Node”+i.ToString();
}
I can assure that you’ll receive the COMException notification!
Since CLR could not find the location out of the range (in this case, the default Row is set to 0 and for each row the Cols value is 5.)

Solution:
==========

Got the Cols and Rows property of the control first and then set value to the corresponding cell. For example:
int cols = this.axMSFlexGrid1.Cols;

int rows = this.axMSFlexGrid1.Rows;

for (int j = 0; j < rows; j++)

{

    this.axMSFlexGrid1.Row = j;

    for (int i = 0; i < cols; i++)

    {

        this.axMSFlexGrid1.Col = i;

        this.axMSFlexGrid1.Text = "Node " + (i*j).ToString();

    }

}

APPENDX:
============
We could manually set the Cols and Rows of the control and then assign each cell a value. Please try it yourself!

posted @ 2009-07-02 16:38 Roahn Luo 阅读(418) 评论(0) 编辑

准备创建一个新的C++ Windows Forms 应用程序,创建倒是成功,但是,界面不太友好!你看下面就知道我在说什么了:

 

 

 

 

 

 

 

 

 

 

 

展开Call Stack, 其内容是关于什么Shell GotDom, 具体信息截屏时侯没注意,其部分内容大概为:
..........
Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_Provider()
..........
到底为啥出现这个问题呢??不太清楚!!!!!VS Bug??

在MSDN转了一圈,也没有发现什么有价值的信息。 不过有个帖子倒是帮了忙:
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/8ff1c859-a9b5-496e-9053-65fd0f852f04

一个比较折中的Workaround还是删掉那个该死的.suo 和 .ncb 文件。

然后重新在Visual Studio中打开, 先View code,然后再View Designer。就这么出来了!

posted @ 2009-07-02 16:05 Roahn Luo 阅读(279) 评论(0) 编辑

Issue Description:


I created a simple website project following the steps below:
 1. Open Visual Studio Team System 2008.
 2. Choos File->New->Website...->ASP.NET Web Site
 3. Location: HTTP
 4. Click Browse.. button, Click Local IIS tab, and click the Create New Web Application button on the top right and input the name, just like follows:

 5. The default.aspx page was open and I simply input a line: Response.Write("Hello"); and set a breakpoint on this line.
 6. Press the green arrow button (F5) and try to debug, what happened, you guess..., I got the error:


Strategies:


1. I looked at many suggestion on ASP.NET forum, like:
http://forums.asp.net/t/1186170.aspx
http://forums.asp.net/t/1094463.aspx

2. Referred to some Feedbacks or KB articles:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=283957&wa=wsignin1.0

But all those are seem not related to my issue.

Solution:


I finally got the solution when I open the IIS Manager->right click Default Web Site->Properties->ASP.NET tab->Edit Configuration...->Application tab-> check the option "Enalbe debugging".
(I did this in IIS6.0, sorry if you have installed other edition.)

After that option has been checked, my Visual Studio Debugger works happily!

posted @ 2009-05-13 17:55 Roahn Luo 阅读(367) 评论(0) 编辑
    只有注册用户登录后才能阅读该文。阅读全文
posted @ 2009-03-26 21:20 Roahn Luo 阅读(20) 评论(1) 编辑

今天调试一C++程序,按下F5,老是弹出一对话框显示信息:debugging information for 'myproject.exe' cannot be found or does not match. No symbols loaded. 翻译成中文大概就是:不能找到'myproject.exe' 的调试信息或者调试信息不匹配。符号文件未加载。

起初,我以为是没有生成.pdb文件的缘故,于是,我右击项目文件,点击属性,展开配置属性节点,展开C/C++节点, 点击了General后把Debug Information Format设置为:Program Database for Edit & Continue(/ZI). 跟着,又检查了其它选项,并且确信在项目文件的Debug文件夹下生成了相应的.pdb文件。

可是做了这些,还是没用。仍然弹出那个该死的对话框。

我于是另外新启动了一个VS实例,新建了一个简单的工程,按下F5, 调试没问题,嘿,这问题到底出在哪儿呢??

然后,我心想,你丫狠!看来我得来点比你更狠的,于是乎,我干脆运行咱的.exe文件,然后单击Visual Studio 的Tools菜单,选择Attach to process..., 并找到我的应用程序,还是没用!!!!我要发疯了!!!!

关键时刻咱得保持冷静!!!!分析下!

第一,我这个工程是前几天做过的。

第二,.pdb文件有,手动加载文件也试过。不过没用。

第三,新建一个项目调试,没问题。

脑袋里突然冒出:是不是.suo文件在作怪??

------解决方案-----

1. 关闭掉Visual Studio 实例。

2. 找到解决方案下的.suo文件并删除之。

3. 重新启动Visual Studio,或者直接双击.sln文件打开

4. 成功调试程序!

后来意识到这是Visual Studio非常严重的问题。因为.suo貌似非常容易损坏,但是它里面包含了许多调试信息,包括项目的打开文件列表、所有的断点、以及监视窗口中所有的内容。

可以运行如下命令来删除掉该文件:del /f /a:h /s *.suo

希望对遇到该类问题的朋友有所帮助!!欢迎提出问题讨论!

 

posted @ 2009-03-15 16:52 Roahn Luo 阅读(2834) 评论(3) 编辑