:) :) this one above is my co-worker, sitting in front of me, I just told him I found the error - he's trying to act big ;P
~~~ From Milano to The Hague, easy as it goes ~~~
:) :) this one above is my co-worker, sitting in front of me, I just told him I found the error - he's trying to act big ;P
~~~ From Milano to The Hague, easy as it goes ~~~
Jesus H. Christ, I was doing the dumbest and biggest mistake - the one you learn NOT to do on Programmers kindergarten, Day One. I was trying to access the assembly outside of a method. Thanks all the same. I just need to sleep more than 5 hours a night...
~~~ From Milano to The Hague, easy as it goes ~~~
Hi, thanks for the quick reply. @Christian: I imported System.reflection, just did not copy here the whole code. @Simon: I do not think it's something about braces, because if i do this:
Assembly theAssembly;
theAssembly = Assembly.LoadFrom("TheDll.dll");
Type theType = theAssembly.GetType("TheType");
// or: Type theType = theAssembly.GetTypes()[0] as I know that there will surely be just one Type in the namespace
I get the error, but if I do this:
Type theType = Assembly.LoadFrom("TheDll.dll").GetTypes()[0]
everything runs fine! and I did not change anything in the rest of the class. Any thought on this?
Hello Everyone, I am trying to get a Type contained into a *.dll file, by means of System.Reflection. After a long and painful Googling journey, I could see that the standard procedure to do this is:
Assembly theAssembly;
theAssembly = Assembly.LoadFrom("TheDll.dll");
Type theType = theAssembly.GetType("TheType");
// or: Type theType = theAssembly.GetTypes()[0] as I know that there will surely be just one Type in the namespace
I don't know if there's something wrong with my VS, my c# compiler or what... but this will NOT compile! First thing first, after I've declared theAssembly
, I cannot access to its methods or properties through Intellisense. If I "force" the above piece of code, I get the Invalid token '=' in class, struct, or interface member declaration
error on the '=' in the second line. Am I doing something wrong? Any help would be much appreciated. Regards, Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
N a v a n e e t h wrote:
BTW, why you need such a solution ?
It is a long story.... :( :( Anyway, i do not need to change it. I just need it to be null, and i know there are some situation in which HttpRequest.UrlReferrer is null. Example: typing a new url in the address bar using browser history using javascript... I need something like that, just server-side. I read around that Response.Redirect has sometimes this behaviour, but not in my case. Any ideas?
~~~ From Milano to The Hague, easy as it goes ~~~
Hello everyone. I have a little application in which there are some main pages, and some detail pages for each main page. in the detail page there is a button which gets you back to one of the main pages. the main page, in the OnLoad method, there is a method which saves the page thet led you there (using HttpRequest.UrlReferrer). I need the main page not to store the urlreferrer of the detail page, passing null as urlreferrer value. I know javascript does this, but for some reason i cannot use it - and i am forced to do everything server-side. Is there some method which sends you to one page, without passing its own url? I googled about it and found lots of pages about people complaining that Response.redirect has this behaviour. I tried, and to my dismay, found that in my application works flawlessly - that is NOT what i want. I need Response.redirect NOT to work, thus passing null as the HttpRequest.UrlReferrer value. I know this is at least confusing, but please try and see if you can give me an hand. Thanks in advance. Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Hello everyone. I have a reporting application, in which you can choose some different kinds of report through a simple ASP.NET menu webcontrol, fed by the regular web.sitemap file. Each report page has several pages of detail, which you access by clicking on one item of those listed in the page. Some of the detail pages are shared between two or more report pages, and the parameters are passed through querystring. Nothing new or weird so far. The big problem started when we were asked to provide a "back" button for each page. This button is based on browser history and should get you back to previous page no matter where you are. Our big issue is that sometimes, accessing a report from the menu seems to clear the browser's history, thus rendering our smart "back" button useless. Is there some undocumented bug in the ASP.NET menu control, which may cause this issue? Any help would be much appreciated. Thanks in advance, Rey9999 UPDATE: the application runs fine in IIS 5.1, the issue seems to be in IIS 6. Also, not only navigating through the menus, but also filtering the report data sometimes clears the history. Any ideas? what is changed between iis 5 and 6 about how history's managed? FURTHER UPDATE: My fault; it is not the web server, but the database which causes the issue. When i use a small test database, everything works. When i use a large production database, the problem shows up. It's almost like the browser "resets" itself when the page takes too long to fetch the data from the DB. BTW, I'm using SQLExpress 2005. Can anybody help? This time I'm really stuck and even googling can't help me. Please give me an hand. :( YET ANOTHER UPDATE: It seems to happen with IE (6 & 7) only. Gecko-based browsers run just fine. Really, can't get head nor tail out of this. Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Well, I found a way out - I don't know if it's good programming practice, but it works. I simply declared MyPowerfulControl as an abstract class, and it automagically disappeared from my toolbox. Should this be a Coding Horror, please let me know ;)
~~~ From Milano to The Hague, easy as it goes ~~~
Hello everyone, I recently started developing a little set of custom controls for a customer of mine. I first began developing one control, then adding the second according to subsequent requests.. and so on. All these controls I deliver in a single, well-packaged DLL file. All of these controls inherits the standard Control Class. But now, since there are many properties shared amongst those controls, I thought that it would have been tidier and clearer to write a class inheriting Control (let us call it MyPowerfulControl), containing all the properties that are used in all of the other custom controls, and then make my other controls inherit from MyPowerfulControl. Nothing seemed to go wrong so far. But now there's a little issue that's bugging me: when I add my custom controls to the toolbox sidebar in Visual Studio, also MyPowerfulControl is shown (and, I kinda not want this). I know that it's possible, when choosing which controls are to be loaded, to un-check the unwanted control. But this is an annoying task for me and my customers... Isn't there a way to tell MyPowerfulControl never to show up, even in the "Choose Control" dialog?
~~~ From Milano to The Hague, easy as it goes ~~~
Thank you. Indeed, I solved the issue with a "dirty trick": after I've populated the DataTable, I check the last row and erase it if it's blank (I do not need to check them all, because the excel files they give me never have blank lines in between, apart from the last one - and that was actually causing the problem amongst my program's users) Thanks again! Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Hello everyone. I have a little application which accepts an excel file, performs a formal check on it (nothing special, it just tries to see if there's a number or a string where they should be) and then inserts the records in a database. This application loads the excel file, puts all the data in a datatable, then performs the formal check. To do so, I use an instance of OleDbDataAdapter and call the Fill(table) method to fill up a table. What is startling me the most is that with some Excel files, if I erase the last row manually (e.g. in MSExcel, clicking in the cells and pressing DEL), the row is not completely erased, so the datatable resulting from the Fill() operation has one last row empty, which is causing the formal check to fail - thus preventing the file to be loaded, since it works in an all-or-nothing basis (one rows fail, the whole file is discarded). The thing that is driving my crazy is that this happens only on SOME excel files! Even using the same Excel installation on the very same machine, some files will show this behaviour, some others won't. Has anything similar ever happened to some of you? I cannot really get a grasp of this. Thanks in advance Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Thank you for the quick reply.
~~~ From Milano to The Hague, easy as it goes ~~~
Hello Everyone. I am creating a custom control. I need to add, amongst its properties, a bunch of lists. One of those is a list of System.Drawing.Color objects. I create the property as usual: private List<System.Drawing.Color> _Colors = new List<System.Drawing.Color>(); public List<System.Drawing.Color> Colors { get { return _Colors; } set { _Colors = value; } }
This, however, seems not to get the things done quite right. Actually, I get this error: Cannot create an object of type 'System.Collections.Generic.List`1[[System.Drawing.Color, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]' from its string representation '(Collection)' for the 'Colors' property.
Do I need to add something to my code to have this property working? Thanks in advance - any help would be much appreciated. Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
The random number approach is a failure: since the page seems to reload the control after the loggingin procedure, I cannot have a unique identifier for each login attempt, beside the page session. But how can I access it from the webcontrol itself? Any help would be much appreciated. Thank you. Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
I could.. but you know, this was not something I needed done for work, it was just to see if I were still able to extend existing cotrols. I liked the "login+captcha" idea, that's all. Anyway, I went with the random number approach, not so elegant but it works. Now I have another problem: How can I tell the control that it first has to check the correctness of the captcha? I tried overriding the event OnLoggingIn, but this seems to happen when the login has already taken place. Any ideas? Thanks in advance Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Hello everybody, I read the excellent article about inserting a captcha control in a webpage, located here[^]. I liked so much the idea, that I wanted to extend the standard Login webcontrol which comes with ASP.NET 2.0, by adding a captcha image to be read and its content typed into a textbox. The solution I found in the article uses the Page Session to generate an unique ID, that is then compared to what the user types. My problem is that when I try to implement the very same solution in the webcontrol, I cannot access the Page object at all! It's like I cannot retrieve the page object my new webcontrol refers to, from within the control itself. Is there some workaround to access the Page property? If not, what could I use to generate an unique ID to be compared? I was thinking of simply generating a random number, but I do not know if it's recommendable. Thanks in advance Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
Good morning everyone. I'm developing an application that listens to incoming TCP/IP socket connections from client applications. the client connects to my server and sends an array of bytes. My application receives it, does some calculation on the bytes and resends the modified byte array back to the client. I was pretty new to socket connections, so i thoroughly read the article "Asynchronous socket communication" here on Code Project. I managed to put up this application and it seems to work (i did not have to develop the client, that is made by another programmer). My problem is that i was recently asked to make this service accessible also on the Internet through a website. I should put up a simple page with a textbox and a button: the user writes a HEX string in the textbox, pushes the button and he's prompted with the result. As a complete newbie to ASP, i first tried the desperate attempt to do the old "cut&paste": after a small adjustment, the very same code i used for a c# test application (that i used to connect to my server app) compiled under ASP. As i load the page, i can see my server application recognizes and accepts the connection; sometimes i even manage to send the byte array; but nothing is received back. I know it was too much to expect this rough approach to work flawlessly: so i think it's better to write it from scratch. Though, after some unproductive googling, my poor (read: none) knowledge of ASP led me to ask for help here. I know it may be laughably simple for you experts, but i really just need to do this: - send a byte array to a specified IP address on a specified port; - keep listening for a similar byte array - display the received code under the form of a HEX string. Please note that due to the heavy calculations needed, the server can take up to two-three minutes before sending the answer. If anyone can help me, or at least can point me out some articles which can enlighten me, i would be very grateful. Thanks in advance, all of you.
~~~ From Milano to The Hague, easy as it goes ~~~
serialport.DiscardInBuffer();
~~~ From Milano to The Hague, easy as it goes ~~~
you could minimize the form to the system tray instead, through a NotifyIcon control, which you can add a context menu to.
~~~ From Milano to The Hague, easy as it goes ~~~
SerialPort port = new SerialPort("COM1"); try { port.Open(); } catch(Exception ex) { MessageBox.Show("Port " + port.PortName + " is already in use") }
~~~ From Milano to The Hague, easy as it goes ~~~