2008年11月2日

今有应用程序 WindowsFormsApplication1 和WebService WebService1.asmx,WindowsFormsApplication1调用WebService1,引用名称为localhost。

WebService代码

Code

 

应用程序代码

Code

 

编译后运行,正常。

使用Dotfuscator对该应用程序进行混淆后运行,调用WebService处引发 System.Configuration.SettingsPropertyNotFoundException 异常,错误信息如下

Code

 

从错误信息中可以看出程序运行时找不到名为“WindowsFormsApplication1_localhost_WebService1”的属性,该属性被混淆器改了名称了,所以找不到。打开Dotfuscator查看“Rename”选项卡,如下图

可以看到有读取属性WindowsFormsApplication1_localhost_WebService1的方法get_WindowsFormsApplication1_localhost_WebService1。要使混淆后的应用程序正常运行,可以选择不重命名“Settings”(选中该项即可)。另外,一样不能重命名WebService的方法,不然会引发“System.ArgumentException: xxxxxx Web 服务方法名无效。”(xxxxxx为服务方法名称)的异常。

不知是否还有更好的方法?

posted @ 2008-11-02 00:09 客家网络 阅读(501) 评论(3) 编辑

2008年10月27日

请看下面的代码段,在IE7中执行后弹出的代码是什么样的呢?

Code

 

测试结果如下,可以发现窗口大小不能调整,并且没有显示滚动条。

 

记得IE6时,窗口的大小可以改变且滚动条也是默认显示的。看MSDN文档,resizable和scrollbars都是默认为yes的。(难道是未更新到IE7)

resizable = { yes | no | 1 | 0 } Specifies whether to display resize handles at the corners of the window. The default is yes.

 

Internet Explorer 7. resizable = { no | 0 } disables tabs in a new window.
scrollbars = { yes | no | 1 | 0 } Specifies whether to display horizontal and vertical scroll bars. The default is yes.

IE7中要调整窗口大小和显示滚动条,应该增加resizable=yes和scrollbars=yes,如下

Code


结果如下图所示

posted @ 2008-10-27 23:15 客家网络 阅读(1994) 评论(0) 编辑

2007年11月22日

此文转载自http://www.dennydotnet.com/post/2007/09/A-DataTable-Serializer-for-ASPNET-AJAX.aspx,未作翻译。

A DataTable Serializer for ASP.NET AJAX, implements JavaScriptConverter. Note that I did not implement a Deserialize method since I am using this for read only data.

[code:c#]
/// <summary>
/// DataTable to JSON converter
/// </summary>

public class JavaScriptDataTableConverter : JavaScriptConverter {
 
public override object Deserialize( IDictionary<stringobject> dictionary, Type type, JavaScriptSerializer serializer ) {
  
throw new NotImplementedException( "Deserialize is not implemented." );
 }
 

 
public override IDictionary<stringobject> Serialize( object obj, JavaScriptSerializer serializer ) {
  DataTable dt 
= obj as DataTable;
  Dictionary
<stringobject> result = new Dictionary<stringobject>(); 

  
if( dt != null && dt.Rows.Count > 0 ) {
   
// List for row values
   List<object> rowValues = new List<object>(); 

   
foreach( DataRow dr in dt.Rows ) {
    
// Dictionary for col name / col value
    Dictionary<stringobject> colValues = new Dictionary<stringobject>(); 

    
foreach( DataColumn dc in dt.Columns ) {
     colValues.Add( dc.ColumnName, 
// col name
      ( string.Empty == dr[dc].ToString() ) ? null : dr[dc] ); // col value
    }
 

    
// Add values to row
    rowValues.Add( colValues );
   }
 

   
// Add rows to serialized object
   result["rows"= rowValues;
  }
 

  
return result;
 }
 

 
public override IEnumerable<Type> SupportedTypes {
  
//Define the DataTable as a supported type.
  get {
   
return new System.Collections.ObjectModel.ReadOnlyCollection<Type>(
    
new List<Type>(
     
new Type[] typeof( DataTable ) }
    )
   );
  }

 }

}



[/code]

 

And how do you implement this? In a web service...

[code:c#]
using System.Web.Script.Serialization; 

//  

[WebMethod()]
[ScriptMethod( ResponseFormat 
= ResponseFormat.Json )]
public string TestJS( int Id ) {
 JavaScriptSerializer toJSON 
= new JavaScriptSerializer();
 toJSON.RegisterConverters( 
new JavaScriptConverter[] new JavaScriptDataTableConverter() } ); 

 DataTable dt 
= new Query( Log.Schema )
   .WHERE( Log.Columns.ID, Id )
   .ExecuteDataSet().Tables[
0]; 

 
return toJSON.Serialize( dt );
}


[/code]

 

That's all there is to it! Just deserialize to an object on the client-side and you're good to go!

Side Note: There is a DataTable serializer from Microsoft in the ASP.NET Futures package.

posted @ 2007-11-22 12:19 客家网络 阅读(468) 评论(0) 编辑

2007年11月21日

摘要: 如何拷贝对象?使用赋值运算符拷贝对象的误区。阅读全文
posted @ 2007-11-21 15:31 客家网络 阅读(88) 评论(0) 编辑

2007年10月24日

默认情况下,Views的目录结构如下:

Views

----Home

--------Index.vm

----Login

--------Index.vm

----…

如果程序中提供多套模板,建议改为如下的目录结构:

Views

----Template1    //模板1

--------Home

------------Index.vm

------------…

----Template2    //模板2

--------Home

------------Index.vm

------------…

 

修改目录结构之后,需要修改Web.config中的配置,如下:

<viewEngines viewPathRoot="Views\Template1">

<add xhtml="false" type="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity" />

</viewEngines>

即通过修改viewPathRoot属性的值来实现更换模板。对于每个用户使用不同模板的情况不适用。

posted @ 2007-10-24 17:07 客家网络 阅读(112) 评论(0) 编辑

2007年10月16日

摘要: Web应用程序中,使用一个xml文件来保存配置信息,并放在了bin目录下,每当对xml文件进行了写操作后,下一次操作都感觉程序特别慢。发生这个情况是因为bin目录下xml文件的改变,造成了程序的重新编译。不要把在程序中可能发生变化的文件放在bin目录下。阅读全文
posted @ 2007-10-16 12:58 客家网络 阅读(86) 评论(0) 编辑

2007年9月28日

摘要: SELECT*FROM(SELECTr.*,ROWNUMasrow_numberFROM表名rWHEREROWNUM<=结束行数)where开始行数<=row_number越靠前的页面显示越快,越靠后的页面显示越慢。SQL出处使用 PHP 和 Oracle 实施分页结果集作者:Harry Fuecks阅读全文
posted @ 2007-09-28 17:20 客家网络 阅读(130) 评论(0) 编辑

2007年8月29日

摘要: jQuery官方网站:http://jquery.com/功能实现:用户在输入文字时,如果能高亮显示正在输入的那个文本框的话,会更人性化些,下面就使用jQuery来实现。实现原理:在document加载完成后(ready),添加input的focus和blur事件,并进行增加和删除样式的操作。代码示例:1<html>2<head><title></titl...阅读全文
posted @ 2007-08-29 13:15 客家网络 阅读(1670) 评论(1) 编辑

2007年8月28日

摘要: 实现原理:记录休眠开始时间,循环判断当前时间与开始时间相隔的秒数,如果超过了指定的秒数,则跳出循环。增加超时是解决换天(23点向0点过渡)的时候会出现的当前秒数比开始秒数小的问题;代码如下:1functionGetCurrentTimeSeconds()2{3//获取当前时间表示的秒数4vard=newDate();56varhour=d.getHours();78varminute=d.getM...阅读全文
posted @ 2007-08-28 11:42 客家网络 阅读(1909) 评论(0) 编辑

2006年8月11日

摘要: 在实际的应用中,往往需要一行显示多条记录,使用DataList控件可以实现本功能。 关键属性: RepeatColumns 设置一行显示多少列,即显示多少条记录。阅读全文
posted @ 2006-08-11 14:18 客家网络 阅读(393) 评论(1) 编辑

导航

公告

发布“图片水印工具”beta版本,欢迎使用,并提出意见与建议。
昵称:客家网络
园龄:6年2个月
粉丝:0
关注:0
<2012年1月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

统计

搜索

 
 

常用链接

我的标签

随笔分类(12)

随笔档案(14)

最新评论

阅读排行榜

评论排行榜

推荐排行榜