_________________________________________________________
**** 4/10 - Global Class not working - Unresolved (10/05/2006)
Resolved (12/05/08)
_________________________________________________________
Atm i am sorting out why my global class isn't working. I created a form to add details about a user, but i was getting an error:
"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object."
So what i guessed was that my global class wasnt instantiating a new list to access. What i did to test this theary was to change the code in the addUser service:
clsUserList userList = new clsUserList();
userList.newUser(prStaffID, prFirstName, prLastName, prJobDescription);
Instantiating the list in the service worked fine, so i believe i have to fix my global class now....
I fixed the problem i was having, i didnt reference the global.asax.vb file in the global.asax file. So the code behind wasnt being used, hence the lists not being instantiated. So it just needed to be inhertited : Inherits="Global"
_________________________________________________________
**** 4/10 - Learning Visual C #
_________________________________________________________
Just took a few days to get to know the new syntax etc. Got a little confused with the dictionarys so got my sis to help me out with just an hour or so of explaining things about this, as well as the global class and general syntax differences to vb.net.
Update(17/05/08)
After programming the whole backend of the application i feel confident in my C Sharp abilities as well as more confident in my programming abilities. It all appears to be working, so i must have done something right :P.
_________________________________________________________
*** 3/10 - Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
(13/05/2008) resolved (13/05/08)
_________________________________________________________
Was having problems connecting to the database. It turns out that the user connection i am using didnt have the rights to even access the database i was using, let alone, read/write etc. So i just typed this error into google and that showed me where to go to change these rights. Which was just in the SQL server management studio, under security and users.
_________________________________________________________
**** 4/10 - Changing from a Dictionary to a List (15/05/08)
_________________________________________________________
I decided to change from a Dictionary to hold the data in the back end, to a List (for reasons as to why read next problem). Because i was changing from a class that was a list of another class, with a key to a basic list of a class (clsUserList Dictionary
I had to delete the lists (clsUserList, clsClientList etc) and move the deleting and saving on clsUser out to the service, I also had to move the editing to the clsUser (its normally in clsUserList). Because i couldnt just access an item using a key anymore i had to write my own small loop to find the object i want (not the best practises but yea) shown below:
Editing:
List
dbConnection lcConnection = new dbConnection();
int length = lcUserList.Count;
for (int i = 0; i <>
{
clsUser lcUser = lcUserList[i];
if (lcUserList[i].PropertyUserID == prUserID)
{
lcUser.Edit(prUserID, prFirstName, prLastName, prJobDescription);
lcConnection.updateUser(prUserID, prFirstName, prLastName, prJobDescription);
break;
}
}
The main reason this was a problem really was because it was the day before i had to have all of this done, and all of a sudden i had to change everything and write new code. At the time i thought it was the end of the world... haha. But alas i succeded and the code was simple was i calmed myself down.
_________________________________________________________
****** 6/10 - Sending a List Back to the Interface (15/05/08) resolved (20/05/08)
_________________________________________________________
This issue is unresolved and i will write more about it when i actually tackle it. At this stage all i know is that there is problems with serialising the list (or dictionary i was going to originally going to implement).
I'll just paste something below that i got from my end of implementation pt. 1 page.
"As you can see in this diagram i originally had a "clsList" for each entity, such as a clsUserList to hold clsUser. The advantage of having a dictionary is that it has a key, then a value Dictionary. This makes the values very easy to search, and sort etc. BUT what i realised is that you cant just pass a dictionary to the interface, but have to send it as an array of some sort and read it back into a dictionary at the other end.
What i decided to do about this was implement a generic list at the backend because only basic searching for editing and deleting needs to be done. This way i can more easily pass the data to the interface and turn it into what i want it to be. I am going to implement a Dictionary at the interface end because alot of searching and sorting is going to be done."
So i think i will just have to write an algorithm that gets the data and puts it into an array, then another at the other end that will take the data and put it into a dictionary.
UPDATE (20/05/08)
I got the passing of the arrays back working :D thanks to an awesome cheeky mohnkey. I asked what he normally does as i had read alot of people just apss back a dataset, and he said to pass back an array of the class, and just .ToArray the list.
[WebMethod]
public clsClientAddress[] getClientAddressList()
{
dbConnection lcConnection = new dbConnection();lcConnection.getClientAddressList();
List
return lcClientAddressList.ToArray();
}
So by passing the list converted to an array we can then grab it by assigning the result to an array of objects. What i was doing wrong from lack of knowledge was getting the data type of the array i was assigning it to wrong. After a bit of playing around i guess this and it worked so huray.
protected void btnGo_Click(object sender, EventArgs e)
{
serviceMain.serviceMain myService = new serviceMain.serviceMain();
object[] lcArray = myService.getClientList();
}
****** 6/10 - Assigning the array to a usable array on the other side (20/05/08) resolved (21/05/08)
_________________________________________________________
int length = lcArray.Length;
for (int i = 0; i <>
{
clsClient lcClient = (clsClient)lcArray[i];
string lcClientID = lcClient.propertyClientID;
lcClientList.Add(lcClientID, lcClient);
}
Array lcArray = myService.getClientList();
foreach (serviceMain.clsClient item in lcArray)
_________________________________________________________
* 1/10 - Small typos etc (this will never be resolved!!!!)
_________________________________________________________
As we all know, when programming til silly hours of the morning we can make many mistakes with syntax, putting code in the wrong place etc. Quite often i will have small issues like:
- Entering the same data into the database twice in the code then wonder why i'm getting a duplicate key error.
- Naming things wrong, or copying and pasting data and not changing the names properly... ^^
*** 3/10 - Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. (16/05/08)
_________________________________________________________
(19/5/08) I got rid of the code that was getting the lists in the global class and this appeared to fix it... so dont really know what was going on there lol. But it is working now...
_________________________________________________________
** 2/10 - Adding duplicates to list (20/05/08)
_________________________________________________________
Today i had an issue with everytime i grabbed the list it would get bigger and bigger. Now in the application start on the service under the global class it makes a new list, SO theoretically everytime it starts it should create a new list? Well it was re-adding items from the database to the list and making the list large with duplicates, I found this out by stepping through and seeing that the list wasnt clearing. I'm not exactly sure how the application start works, so i thought i'd be safe and clear the lists before filling them again.
dbConnection lcConnection = new dbConnection();
Global.clientAddressList.Clear();
lcConnection.getClientAddressList();
List
return lcClientAddressList.ToArray();
So that will do for now, in future the logic and process of how this works will change, as is it will all be called differently, but was probly a problem i was going to face either way.
_________________________________________________________
** 2/10 - Login Not Working
_________________________________________________________
Was loading up the forms, and i was already logged on as ADMIN/EDITHZOR, this is not what i wanted. I also could not log out or log on. What i realised was that i was sposed to set up SQL for ASP alot earlier running c:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe, going through this then allowed me to use the users i set up in ASP.NET Configuration.
_________________________________________________________
**** 4/10 - Webservice not working, ACCESS DENIED! 30/5 early morning ;)
_________________________________________________________
This problem aroseon the 29th just before my project meeting, i sort of spent the rest of the day after that, besides sleeping trying to figure it out. The reason i give this a 4 is because any problem that stops me from using the service at the point will cost me alot of time, so this could have been alot worse. Below is my conclusions i made on todays blogg:
I fixed the problem i was having with my virtual machine. I got a blue screen of death and things went down hill from there yesterday, but the issue i was having and the blue screen of death arent related, my thinking is, that because the blue screen of death happened i was forced to restart the server and restart IIS. So the original error i was getting was a nasty long with with a few parts, first of all 'text/html; charset=utf-8', but expected 'text/xml' and a whole heap of crap under that, the second part to mention is "[HttpException]: Failed to start monitoring changes to C:\Inetpub\wwwroot because access is denied."So the first thing i did was have a look at what had cause this same wierd html error the first time, which isnt something that could fix this problem. So i assumed that this was an error thrown back at you if the web service wasnt working. So i moved down to the next obvious error and where it was happening which is the http exception. I spent a long time thinking that it was a user permission problem some where along the line, and after creating numerous users on the main website directory and changing around permissions to no avail i found a handy website that mentioned changing the IIS ASPNET settings to framework 2.0. Now this actually sounded familiar.. i mean it should be set to 2.0 anyways shouldnt it? So i gave it a go AND IT WORKED. Very ametuer mistake i admit, but i havent played around with IIS in a long time haha.So thanks Rahmat Faisal : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=177088&SiteID=1So i think why this only happened now and after the VMBSOD (Virtual Machine Blue Screen of Death) is because IIS restarted and put in place the fact that i had changed from windows authentication mode to forms mode. So framwork version 1 may not have been able to handle this, and i was getting problems with my web.config.
*** 3/10 - Deleting and Editing of Items in Form View 30/5
_________________________________________________________
The deleting of records isnt working at the moment, this is due to the form not passing in the data field to the class, so it doesnt know which key to delete. The same goes for editing on two of the items (client address and management address). Once i get time i will look into this, but for now i must move on.
_________________________________________________________
*** 14/8 to 20/8 - Manually implementing Javascript and Google maps into ASP.NET
_________________________________________________________
Going to figure out the manual way of doing the mapping part. At the moment i'm having an issue with ClientScriptManager.RegisterForEventValidation. Seems to be some problem with having the map, and it doing things client side.I found this bit of info as to what it is.
"Balance the security benefit of event validation with its performance cost Controls that derive from the System.Web.UI.WebControls and System.Web.UI.HtmlControls classes can validate that an event originated from the user interface that was rendered by the control. This helps prevent the control from responding to spoofed event notification. For example, the DetailsView control can prevent processing of a Delete call (which is not inherently supported in the control) and being manipulated into deleting data. This validation has some performance cost. You can control this behavior using the EnableEventValidation configuration element and the RegisterForEventValidation method. The cost of validation depends on the number of controls on the page, and is in the range of a few percent. Security Note It is strongly recommended that you do not disable event validation. Before disabling event validation, you should be sure that no postback could be constructed that would have an unintended effect on your application."
http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic30477.aspx
I think its because i'm using subgurim, and with the advanced directions it uses input from the user, which i dont need at all. So i am going to skip this, because i dont need to sort it out, just need to not use the subgurim method that is causing this.
Basically what i needed to do was add the key reference in web.config (which i had).Add code in the page_init part of the aspx.cs file for loading the key into the head part of the page, so that google knows its valid.Add a buttonAdd the code behind the button either in page_init or page_load.code:
Think i tried to rush into understanding it too quick, so what i did today was step back and learn different parts of it, such as testing if google maps even worked in basic html on my page, which it did. Then moved on a page.clientscript.register... to see if that worked even with the most basic alert function, which it did.
So i didnt see why the google stuff shouldnt work now that i knew how to use a button. I then came accross a couple of errors from google maps which slowed me down a bit, 'gmap2' is undefined and 'object expected'. I soon figured out that this was because i had commented out the code which set up my app key, which would mean that google wouldnt allow me to have a map.
In the end this was easy, just got to put the code in the right place. Also instead of running a javascript function when a button is pushed, i just needed to put the javascript code into my asp button_click code to run. So that way there isnt any specific button or anything to make this code go off, it just runs in the code.
No comments:
Post a Comment