NET Error Message:
System.BadImageFormatException was unhandled
NET Error Message:
System.BadImageFormatException was unhandled
I was successfully get the DLL with below step in Win7,
Note:
There is no GAC folder if you access with Windows File Explore. Only avaiable with Command line.
Have fun.
And you can using following code to use a GAC assembly,
Background (steps to put a DLL in GAC)
First, in the command prompt, go to the folder in which the project DLL is saved. Then, create a strong name for that DLL by using the command sn -k [strong name.snk]. Then, put that strong name in the [assembly: AssemblyKeyFile("strongnamepath")] line in assemblinfo.cs, and build that project. Again in command prompt, type gacutil /i [assemblyname]. Now, the DLL is moved to GAC. In the code available for download, you will find out how to use the GAC DLL.
Using the code
You need to move the correct DLL to the GAC by following the above steps. In our example, PutitinGAC is the DLL to be moved to GAC.
The first step to do to refer a DLL in GAC is to assign it to the local assembly object fromGAC. While loading, the DLL version number and public key token should match that of the DLL in the GAC (c:\Winnt\assembly). In the DLL’s properties, you can find the public key and version details.
[code:c#]
Assembly fromGAC = Assembly.Load("PutitinGAC, " +
股票数据的获取目前有如下两种方法可以获取:
1. http/javascript接口取数据
2. web-service接口
1.1Sina股票数据接口
以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据
接口:
这个url会返回一串文本,例如:
If your application redirects (navigates) from one ASP.NET Web page to another, you will frequently want to pass information from the source page to the target page. For example, you might have a page where users can select items to purchase. When users submit the page, you want to call another page that can process the information that the user has entered.
You can pass information between pages in various ways, some of which depend on how the redirection occurs. Options include the following:
Use a query string, which appends information onto the URL of the target page. You can use a query string when using a HyperLink [ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink(VS.80).aspx ] control to build navigation into a page or when you are programmatically redirecting to another page using the Redirect [ http://msdn.microsoft.com/en-us/library/t9dwyts4(VS.80).aspx ] method.
Passing values in a query string works even if the pages are not in the same Web application; it also works if you want to pass information to a page that is not an ASP.NET Web page. If the target page is an ASP.NET Web page, you can read the value of the query string out of the QueryString [ http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring(VS.80).aspx ] property of the HttpRequest [ http://msdn.microsoft.com/en-us/library/system.web.httprequest(VS.80).aspx ] object.
Note |
|---|
|
Never pass sensitive data using a query string, because the information is visible to users and can easily be modified, thus representing a potential security risk. |
Use session state to store information that is then accessible to all ASP.NET Web pages in the current application. However, this takes server memory, and the information is stored until the session expires, which can be more overhead than you want for simply passing information to the next page. For details, see ASP.NET State Management Overview [ http://msdn.microsoft.com/en-us/library/75x4ha6s(VS.80).aspx ] .
On the target page, read control values and public property values directly out of the source page. This strategy works in two situations: when the source page cross-posts to the target page (for more information, see How to: Post ASP.NET Web Pages to a Different Page [ http://msdn.microsoft.com/en-us/library/ms178140(VS.80).aspx ] ), and when you call the Transfer [ http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.transfer(VS.80).aspx ] method to transfer execution from the source to the target page on the server. The strategy of reading values directly from the source page is described in this topic.
If you are designing the source page specifically for sharing information with target pages, and both pages are ASP.NET Web pages, in the source page you can add public properties that expose information you want to share between pages. You can then read the values of the properties in the target pages.
Note |
|---|
|
You can read source page properties in the target page only if both pages are in the same Web application. |
On the source page, create one or more public properties.
The following code example shows a property named CurrentCity that exposes the value of a TextBox [ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox(VS.80).aspx ] control named textCity.
Public ReadOnly Property CurrentCity() As String Get Return textCity.Text End Get End Property
ASP.Net 1.1后引入了对提交表单自动检查是否存在XSS(跨站脚本攻击)的能力。当用户试图用之类的输入影响页面返回结果的时候,ASP.Net的引擎会引发一个 HttpRequestValidationExceptioin。默认情况下会返回如下文字的页面:
Server Error in ‘/YourApplicationPath’ Application
A potentially dangerous Request.Form value was detected from the client
(txtName=”“).
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (txtName=”“).
….
这是ASP.Net提供的一个很重要的安全特性。因为很多程序员对安全没有概念,甚至都不知道XSS这种攻击的存在,知道主动去防护的就更少了。ASP.Net在这一点上做到默认安全。这样让对安全不是很了解的程序员依旧可以写出有一定安全防护能力的网站。
但是,当我Google搜索 HttpRequestValidationException 或者 “A potentially dangerous Request.Form value was detected from the client”的时候,惊奇的发现大部分人给出的解决方案竟然是在ASP.Net页面描述中通过设置 validateRequest=false 来禁用这个特性,而不去关心那个程序员的网站是否真的不需要这个特性。看得我这叫一个胆战心惊。安全意识应该时时刻刻在每一个程序员的心里,不管你对安全的概念了解多少,一个主动的意识在脑子里,你的站点就会安全很多。
为什么很多程序员想要禁止 validateRequest 呢?有一部分是真的需要用户输入”<>“之类的字符。这就不必说了。还有一部分其实并不是用户允许输入那些容易引起XSS的字符,而是讨厌这种报错的形式,毕竟一大段英文加上一个ASP.Net典型异常错误信息,显得这个站点出错了,而不是用户输入了非法的字符,可是自己又不知道怎么不让它报错,自己来处理报错。
对于希望很好的处理这个错误信息,而不使用默认ASP.Net异常报错信息的程序员们,你们不要禁用validateRequest=false。
正确的做法是在你当前页面添加Page_Error()函数,来捕获所有页面处理过程中发生的而没有处理的异常。然后给用户一个合法的报错信息。如果当前页面没有Page_Error(),这个异常将会送到Global.asax的Application_Error()来处理,你也可以在那里写通用的异常报错处理函数。如果两个地方都没有写异常处理函数,才会显示这个默认的报错页面呢。
举例而言,处理这个异常其实只需要很简短的一小段代码就够了。在页面的Code-behind页面中加入这么一段代码:
protected void Page_Error(object sender, EventArgs e)
{
方法一:
现在假设有两个页面A、B,我们的目的是把A页面的数据提交到B页面。
首先在A页面建立B页面需要访问A页面的数据项的访问属性。
Some old story: works locally, get’s screwed up on deployment:
Description: The application attempted to perform an operation not allowed by the security policy.
Today, I found a great solution to create Multilingual Websites (Localization)