Fórmulas e Cenas

Object Reference Not Set to Instance of an Object

  Home  |   Contact  |   Syndication    |   Login
  39 Posts | 0 Stories | 6 Comments | 0 Trackbacks

News

Archives

Post Categories

Links

Geral

If you have a "{" or "}" inside a string when using string.format you will get the error mentioned in the title. To fix this you must double the charater. Error Example: string teste = string.Format(" This is a {teste} {0} ", mystring); Correct Example: string teste = string.Format(" This is a {{teste}} {0} ", mystring);v...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

In global.asax: protected void Application_BeginRequest(Ob... sender, EventArgs e) { HttpRuntimeSection runTime = (HttpRuntimeSection)WebConf... //Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload size int maxRequestLength = (runTime.MaxRequestLength - 100) * 1024; //This code is used to check the request length of the page and if the request length is greater than...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

<script type="text/javascript" language="javascript"> Sys.WebForms.PageRequestMan... function refresh() { //Your code here; } </script> Source
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

/* Processes that are blocking others */ select * from sysprocesses where spid in ( select blocked from syslocks l inner join sysprocesses p on p.spid=l.spid where p.dbid=5 -- Database ID and p.blocked<>0 ) /* Processes being blocked*/ select p.* from syslocks l inner join sysprocesses p on p.spid=l.spid where p.dbid=5 and p.blocked<>0
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

FileInfo fileInf = new FileInfo("c:\myfile.txt"); FtpWebRequest reqFTP = (FtpWebRequest)FtpWebReques... Uri("ftp://myFTPSite/myfile... reqFTP.Credentials = new NetworkCredential("myUser",... "myFTPDomain"); reqFTP.KeepAlive = false; reqFTP.Method = WebRequestMethods.Ftp.Uploa... reqFTP.UseBinary = true; reqFTP.ContentLength = fileInf.Length; int buffLength = 2048; byte[] buff = new byte[buffLength]; int contentLen; FileStream fs = fileInf.OpenRead(); try { Stream strm =...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

FileStream outputStream = new FileStream("c:\myfilefolder... FtpWebRequest reqFTP = (FtpWebRequest)FtpWebReques... Uri("ftp://myFTPSite/file.t... reqFTP.Method = WebRequestMethods.Ftp.Downl... reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("myUser",... FtpWebResponse response = (FtpWebResponse)reqFTP.GetR... Stream ftpStream = response.GetResponseStream(); int bufferSize = 2048; int readCount; byte[] buffer = new byte[bufferSize];...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

FtpWebRequest reqFTP = (FtpWebRequest)FtpWebReques... Uri("ftp://myFTPURL/")); reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("myUser", "myPassword", "FTPDomain"); reqFTP.Method = WebRequestMethods.Ftp.ListD... WebResponse response = reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetRe... string line = reader.ReadLine(); while (line != null) { line = reader.ReadLine(); } reader.Close(); response.Close(); Enjoy :)...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

The scenario: Imagine someone asks you to create an XML file with some data structure. The approuch: There are several ways to achieve this, the fastest and less time comsuming is to create a class structure that represents the XML structure you need, fill in with the data and them serialize it to a string and save it to a file. The Implementation: Lets say you need a single node, followed by an array of nodes. Class Definition: public class MyNode { [XmlElementAttribute("code")] public int code;...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Occasionally an application that I am working on throws the above error... After trying to fix my code for a bit, and not finding the problem I googled a bit and discovered that this error is caused by a windows service that must be running. So, if you ever encounter this error, you must turn on the 'Distributed Transaction Coordinator' in order to solve it. Hope this helps. Original source: http://geekswithblogs.net/n...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

update n set n.fieldToUpdate=o.fieldToUp... from originaltable o inner join toTable n on n.id= o.id...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Full Geral Archive