使用VS2010的时候,有时候会出现“COM 对象与其基础 RCW 分开后就不能再使用。”的错误,可是我们什么都没有做,为什么会这样,网上的资料大都是在介绍和解释什么是RCW,讲的是.Net和COM互操作的一些相关知识,但是我们今天的重点是如何解决“COM对象与其基础RCW分开后就不能再使用”的问题,使用了各种方式,有种方式最起作用:重新引用Microsoft.CSharp命名空间。
1、先删除引用,再重新添加引用

深层的原因,请高手讲解。
posted @ 2011-11-13 18:12 cry 阅读(272) 评论(0) 编辑
asp.net vs2010 设计报表rdlc时,未能加载文件或程序集
|
我在一个网站中设计rdlc报表时,点击报表数据中 新建数据集会弹出 “未能加载文件或程序集“XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。”这样的错误,无法进行后续操作 终于找到了答案:需要手工把要引用的dll复制到C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies 下,已解决了 另外还提到: 另外需要设置一下ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); 不知这是什么用的。没设置这个 |
posted @ 2011-09-02 23:18 cry 阅读(217) 评论(1) 编辑
摘要: 地址:http://www.codeproject.com/KB/viewstate/ViewStateAttribute.aspx背景当我们在页面中创建一个ViewState,我们通常为ViewState创建一个属性,像这样:[代码]你不觉得创建2个访问器有点令人讨厌吗?能够使这个简单一些像一个自动的属性吗?像这样:[代码]或者[代码]代码详情第一步:让我们创建一个从System.Web.UI....阅读全文
posted @ 2010-01-31 22:31 cry 阅读(121) 评论(0) 编辑
代码
using System.Text;
namespace CSTest
{
class StrOp
{
/// <summary>
/// 得到字符串的长度,一个汉字算2个字符
/// </summary>
/// <param name="str">字符串</param>
/// <returns>返回字符串长度</returns>
public static int GetLength(string str)
{
if (str.Length == 0) return 0;
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
byte[] s = ascii.GetBytes(str);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
}
return tempLen;
}
public static string CutString(string str,int len)
{
if (str.Length == 0) return str;
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
byte[] s = ascii.GetBytes(str);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
if (tempLen > len)
{
tempLen = i;
break;
}
}
str = str.Substring(0, tempLen);
return str;
}
}
}
namespace CSTest
{
class StrOp
{
/// <summary>
/// 得到字符串的长度,一个汉字算2个字符
/// </summary>
/// <param name="str">字符串</param>
/// <returns>返回字符串长度</returns>
public static int GetLength(string str)
{
if (str.Length == 0) return 0;
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
byte[] s = ascii.GetBytes(str);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
}
return tempLen;
}
public static string CutString(string str,int len)
{
if (str.Length == 0) return str;
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
byte[] s = ascii.GetBytes(str);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
if (tempLen > len)
{
tempLen = i;
break;
}
}
str = str.Substring(0, tempLen);
return str;
}
}
}
改写别人的方法,得到CutString,初步测试,满足要求
测试如下:
代码
using System;
namespace CSTest
{
class Program
{
static void Main(string[] args)
{
string strText = "12wd中国人中國人";
Console.WriteLine("调用GetLength方法:" +
StrOp.GetLength(strText));
Console.WriteLine(strText.Length);
Console.WriteLine(StrOp.CutString(strText, 15));
Console.ReadKey();
}
}
}
namespace CSTest
{
class Program
{
static void Main(string[] args)
{
string strText = "12wd中国人中國人";
Console.WriteLine("调用GetLength方法:" +
StrOp.GetLength(strText));
Console.WriteLine(strText.Length);
Console.WriteLine(StrOp.CutString(strText, 15));
Console.ReadKey();
}
}
}
测试结果:

posted @ 2010-01-21 22:15 cry 阅读(58) 评论(0) 编辑
摘要: 效果图:IE6.0上存在大家都熟知的一个Bug:div不能覆盖select控件js code :[代码]在页面上添加一个textbox和一个隐藏域: <input id="select_park1" class="CityBD_3 maall5 ListText" runat="server" type="text" readonly="readonly" value="-花园类型-" /&...阅读全文
posted @ 2009-05-09 17:10 cry 阅读(1502) 评论(3) 编辑
摘要: HTML文件路径:相对路径(Relative Path)如何表示同级目录的文件2.html和3.html在同一个文件夹下, 如果2.html链接到3.html,可以在2.html中这样写:<a href="3.html">同目录下文件间互相链接</a>如何表示上级目录的文件1.html是2.html和3.html的上级目录中的文件,如果2.html或3.html链接到1.h...阅读全文
posted @ 2009-05-04 13:11 cry 阅读(309) 评论(0) 编辑


