Hello, i want to know if there is a class in the .net framework to parser an MailMessage to an string, i mean, take all its properties,headers,etc, and return an string with those values..something like...
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("< from >", "< to >", "< subject >", "< body >"));<br />
string commandToSend = Parser.Convert(message);<br />
I need the string value because it will be send to a service for spam evaluation.
Sorry for my bad english, its not my primary language.
can anyone here to tell me, how to copy the text / contents from browser by using C# code under button_click event, in VS. net for smart devices?
please reply urgently, i shall be thankful to them.
I created a C# console application (without GUI) that scrapes information from webpages. This application runs everyday on a unattended computer with Win2003 SP3, including latest security patches and up to date virusscanner, using a scheduled task. It uses the C# System.Windows.Forms.WebBrowser class to navigate the pages.
The application runs fine for weeks but all of a sudden the following error occurs
Win32Exception details: HRESULT=-2147467259 ecode=87 inner=
Failure... System.ComponentModel.Win32Exception: The parameter is incorrect
at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
An important code snippet:
public class Scraper
private WebBrowser browser;
public void Scrape()
using (browser = new WebBrowser())
The application is started every hour. It will run OK for days, until the exception occurs. When the exception occurs it keeps occuring. BUT when a user logs into the system and opens a browser and closes it again. The system runs fine for a couple of days again, until the exception shows up again (from that point on it will continue to fail again until somebody logs on... etc).
The exception is "The parameter is incorrect", but because I don't provide any parameters I don't have a clue which parameter might be incorrect and why.
I examed internet explorer settings on the machine and even scanned the registry for strange settings, but couldn't find anything that could point me in the right direction.
I also looked at the running processes. I examined which processes are running when the problem occurs and when the system is running fine, but there are not differences.
I am a kind of desparately looking for good ideas or background info that can point me in the right direction.
the WebBrowser documentation states:
The WebBrowser control is resource-intensive. Be sure to call the Dispose method when you are finished using the control to ensure that all resources are released in a timely fashion. You must call the Dispose method on the same thread that attached the events, which should always be the message or user-interface (UI) thread.
The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.
Your code uses the using statement, so Dispose is called.
The other requirements need to be verified.
The exception is an inner exception; ecode=87 means invalid parameter,
and HRESULT=-2147467259 corresponds to hex 80004005 which inside good old winerror.h
is the value for the symbols ERROR_REC_NON_EXISTENT as well as E_FAIL. so that
seems not to help us.
One guess is each new WebBrowser creates a new class name, and somehow these class
names suddenly are not valid any more. Suggestion: count and log each new WebBrowser
and try to recognize a pattern in the failures.
Another idea is something runs out, e.g. disk space for temporary internet files;
you might try to see if something like that occurs, and can be remedied without
launching IE, just to see if your app resumes normal operation.
Both the dispose (through the using statement) and the single thread apartment (STA) were already in place. Your comments show that I was on the right track adding those two.
I already checked the processes and active webbrowsers and system resources, but nothing can be seen there.
This weekend the server was rebooted, which killed some processes. Of course with the reboot the errors disappeared. Because I did not reboot the system since I implemented the STA and dispose actions, some problem processes might have been left in memory. Possibly this reboot might have solved this and could lead to a long-term solution.
I can only be sure if this works after a week or so. Then I'll report the final conclusion. Again, thanx for the input.
The solution seems to work. The Using Statement caused the Dispose function of the Webbrowser to be called. This solution was already implemented, but the problem remained.
Because the old version of the software, where the Dispose was not called, was running before, old "resource claims" probably were still active.
A reboot of the system seems to have solved the problem by releasing those claimed resources. The system is running fine now for a month now, while before to the problem occured every 4 or 5 days at least.
I was wondering if anyone knew of any articles relating to GIS programming specifically for C#?
I would like to know more about plotting longitude and lattitude coordinates onto a vector diagram but am unsure how to go about rendering these vector diagrams in the first instance. Basically I suppose I am looking to build a GIS Vector viewer using C# but am at a loss as to where I should begin.
I have a pretty good understanding of C#. I understand GIS to a degree but what I suppose I am not clear on is displaying the information. By that I mean if I have a dxf file, I would know how to read the file, plot the points and join these up. But the thing I cannot get my head around is if I had a vector diagram (dxf format again, say a shot of the Grand Canyon), obviously this is Geo-positioned, but if I was to plot a point on that diagram, how would I do that? How would I set my viewer up to handle well 'space' I guess. I could plot a point, but would it be displayed accurately on the diagram?
I know we have various coordinate systems, but I am unsure how to code this into an actual viewer.
This project is something I have wanted to do for a long time. Basically I want to take a vector image of a town and load on top of that coordinates from a GPS session plotting the route taken. It is purely for, ahem, 'fun' although it is currently driving me a bit potty. If I could just get to grips with how I present images within a coordinate system, I think I would be in a slightly better position.
I realise this is a bit fragmented and aplogise for this. If you have any further questions, please let me know and I will do my best to answer these clearly.
Well I've done a lot of work with Ordnance Survey Grid References[^] but these deal only with Cartesian coordinates, i.e. an X and a Y. The first major question to ask yourself is are you going to deal with 2D data or 3D. I realise that coordinate systems aren't that straight forward because of the skews etc.
But basically what you would want is if you can load your image of the town with a known coordinate, e.g. the top-left corner of the town-hall is so many degress/minutes/seconds north and west then when you read in your GIS data you can use this as your origin for calculations.
but I am unsure how to code this into an actual viewer.
So if I've understood you correctly you can read the vector files but don't know how to display them?
If you don't know how to draw them then you have 3 possibilities (well actually two), you can use GDI+ with C#, Managed DirectX or WPF. What I meant by having 2 is that WPF uses DirectX internally and even is easily capable of 2D or 3D data very simply as well as all the graphics transformations. However if you're not on Vista or XP SP2 then you're stuck on that front.
For example I've got portions of Great Britain in the OS format 1:25000 (1km = 4cm), these are stored as pictures 200 pixels by 200 pixels. With this information I know that the name of the picture refers to the Grid Reference in the bottom left corner of the picture. 200 pixels then equals 1km.
So if I wanted to plot the point SN512876 I would draw the pictures stored in file SN510870.png (this is the point 51km west and 87km north of the origin for the grid code SN, see linked article if you want to know more). That's the base image loaded (the town in your case), I then have to plot the more accurate point.
So for the X coordinate (in pixels) from the bottom-left of the picture:
x = (512 - xOffset) * ScalingFactor
y = (876 - yOffset) * ScalingFactor
Where the xOffset = 510 and yOffset = 870. The scaling factor in this instance is 20 because 200 pixels = 1km so 0.1 of a km = 20 pixels.
So in summary the most important things to get are a known coordinate on the image and the scaling of the image, for example you need to know how wide / tall the image is so that you can scale things accordingly.
I see where you are coming from. I had in my mind something along those lines, but your explanation has cemented a few ideas I had.
I have dealt with Rasters before, but mostly in the likes of MapInfo or SmallWorld but on the basis of what you said I think I could now develop a viewer for that. I would assume Vector wouldshare the same principles