|
There is a WebRequest object that allows you to make http requests, see this for a specific answer to your question: http://support.microsoft.com/kb/307023[^]
Normally, when consuming web-services, the client uses a set proxy class generated from a web service description. This creates intermediary classes for sending the data up and down the wire and proxy classes to handle the consumption of the remote methods. If you are consuming a third party service, it is worth asking the provider how to generate these first as hand-rolling can be a PITA. If you are writing the services yourself, you'll be able to just add the service as a reference. Right click the client project and select "Add service reference" and point it at your definition. Both ASMX (IIRC) and WCF services provide service definitions out the box.
|
|
|
|
|
hello everyone
i need a suggestion, actually my C# project developed on vista
32-bit i3 system generate error on vista 64-bit AMD processor system.
error is .........
<pre lang="css">
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: myapp.exe
Problem Signature 02: 3.0.1.5
Problem Signature 03: 4e33b2b6
Problem Signature 04: mscorlib
Problem Signature 05: 2.0.0.0
Problem Signature 06: 47577b16
Problem Signature 07: f8f
Problem Signature 08: 80
Problem Signature 09: System.IO.FileNotFoundException
OS Version: 6.0.6001.2.1.0.256.6
Locale ID: 1033
</pre>
this one is error and as i searched about it i found one of dll may be not
found related with excel file creation module.
but i added microsoft excel 12.0 object library and my project
run on win7 64-bit amd processor system.
so give me any suggestion if u know about this error
thank u in advance
|
|
|
|
|
We have no idea what you're app does, what is uses, other than Office, or what file it's looking for. Most of the error details you posted are utterly useless. The only useful bit what the FileNotFound exception.
Does the machine have the appropriate version of Office installed?? If not, you need to install it. The office Interop library is not enough.
If your code is using OleDb to read the data in an Excel file, you'll have to specify that. The connection string you used would also need to be shown.
|
|
|
|
|
thank u so much for ur reply
after ur reply
i tried to run my project without using excel module
and related dll and still i got this error........
mainly i used dll
- imapi2.interop
- Interop.IWshRuntimeLibrary : to create shortcut file
- Interop.shell32
- Interop.WbemScripting
that's all...........
now i m more confused. project executed on win7 with 64 bit AMD Processor
but failed on Vista with 64bit AMD processor...
|
|
|
|
|
It fails probably because of IMAPI2.
Create a Setup project in your solution so you can install your application on another machine and have the stuff that's missing installed.
Not every machine has all of this stuff available to your app, so you have to make sure you bring it with you.
|
|
|
|
|
after ur suggestion i tried myproject without using
imapi2 dll but still i got this error.
ok i don't know exactly but may be there is compatibility issue
with vista AMD 64 bit processor...........
my app is developed on vista 32 bit intel processor..........
thank u ..........
-- Modified Monday, August 1, 2011 8:41 AM
|
|
|
|
|
Aisha sharma wrote: may be there is compatibility issue with vista AMD 64 bit
processor...........
There's no such thing.
This is not a compatibility issue. This is happening because you didn't ship all the required libraries your app needs with your app. Just shipping the Interop files is not enough. You have to install the .DLL's those Interop files call with your app in case they are missing on the target machine.
I already told you what to do.
|
|
|
|
|
i m trying to find problem.
now i m confirm about this.
thank u so much for ur suggestions
|
|
|
|
|
after some testing conclusion is :
project not run on vista with amd processor
exception occured on form's InitializeComponent() method.
and run on vista with intel processor....
after installig visual studio it work fine on vista with amd processor.
if u require any other info then let me know.......
thank u
|
|
|
|
|
Again, and for the last time, it has NOTHING to do with the processor.
Since you installed Visual Studio on the bad machine, you installed a bunch of components on that machine as well. Obviously, your application reuiqres one of those components that you did not install on the target machine.
You cannot just copy your bin folder to the target machine and expect it to work. It will for simpler apps, but yours is requiring a components that has to be installed and you are not shipping with your .EXE.
How do I know this? Because the error popped up in your InitializeComponent call. You're more than likely using a control that doesn't exist on the target Vista machine.
|
|
|
|
|
my problem is solved.
i always checked my project using proper setup.
problem occured due to System.Core.dll not
found on system.........
|
|
|
|
|
That would mean that either the correct .NET Framework wasn't installed or the installation was screwed up, which is a very rare occurrence.
|
|
|
|
|
I saw some nasty code recently. A function took a parameter of a type that was something like Func<int, int,="" string,="" mytype="">. You get no clues about the parameters.
When (if ever) should we use Lambdas? They seem like a shortcut which will save some time during the initial development, but lose more time later. I think the old fashioned way will almost always be more readable.
One place where lambdas tend to be useful is when using LINQ (to SQL or Entity Framework). Is it really that good though? SQL is designed for the job, and performs MUCH better, so why use LINQ to SQL? If we have automated tests then we can fully test that the code is correctly wired up to the SQL.
|
|
|
|
|
They're useful shortcuts. Func is just a shortcut for when you don't want to define a delegate yourself. These are all pretty much equivalent:
Func<string, bool>
Predicate<string>
delegate bool MyStringTest(string s)
Lambda expressions themselves, I find extremely useful... I love being able to type:
People.Where(a=>a.FirstName.StartsWith("B"));
This use of lambdas has nothing to do with SQL, aside from a syntax resemblance between the long-form LINQ queries and SQL queries (I prefer the shorthand notation).
Remember that LINQ extensions aren't only made for database access... They're great for working with collections.
|
|
|
|
|
Exactly, it was made for querying an array of objects. If you are working with db connection you would more use T-SQL. With using lamdba's, yeah, they are handy but if the code is long, or if the method is virtual/abstract I would prefer not to and more than not, I mainly only use them in the LINQ querying on array types unless it is complex where I would return Predicate/Func/Action from a methods also where I could add some more parameters to help my need in filtering.
|
|
|
|
|
A lambda expression makes a good short-cut for many well known items, every wanted a one off-anon event, lambda, want to sort a list and not implement IComparable, lambda. However, I often refactor many of my lambda expressions into real code.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: I often refactor many of my lambda expressions into real code
True. Same with the Nullable<T> and Tuple<x,y,z> .
Greetings - Jacek
|
|
|
|
|
Member 4487083 wrote: the old fashioned way will almost always be more readable
I'm with you, mainly because I'm old-school .
But I suppose it's similar to using a Regular Expression rather than writing a custom parser. Or even like including SQL in your code rather than calling an API of some sort.
|
|
|
|
|
PIEBALDconsult wrote: B<layer>ut I suppose it's similar to using a Regular Expression rather than writing a custom parser. Or even like including SQL in your code rather than calling an API of some sort.
Pretty good analogy actually.
Mainly because people misuse those all the time too.
And as for "custom parser" there are probably quite a few cases where people attempt to use a regex when they problem can be solved with nothing more than a simple index or split.
|
|
|
|
|
Member 4487083 wrote: When (if ever) should we use Lambdas?
Almost never.
Member 4487083 wrote: and performs MUCH better, so why use LINQ to SQL?
Perhaps to demonstrate that one doesn't in fact know exactly what you said?
|
|
|
|
|
Func is a generic type, you'd usually have information about the parameters.
Lambdas are really nice for simple functions (in the mathematical or FP sense), where the boilerplate text for defining a method would be a significant portion of the code, and where the calculation type is simple enough that everything can be inferred (by the reader; the computer has no problem anyway!). I've also seen them used for event handlers, where the parameter types are well known.
LINQ to SQL, if used correctly, creates queries very similar to what you'd make yourself, and manages the result in a much more friendly fashion. It doesn't have that much to do with lambdas though apart from the query related functions that take a lambda parameter.
|
|
|
|
|
Im trying to figure out how to create an array in my class. What I have now is:
namespace Computer_Specs
{
class Computer
{
private string _Brand;
private int _RAM;
private string _cpuBrand;
private float _cpuSpeed;
private string _operatingSystem;
private string[] _clArray = new string[5];
public string brand
{
get { return this._Brand; }
set { this._Brand = value; }
}
public int ram
{
get { return this._RAM; }
set { this._RAM = value; }
}
public string cpuBrand
{
get { return this._cpuBrand; }
set { this._cpuBrand = value; }
}
public float cpuSpeed
{
get { return this._cpuSpeed; }
set { this._cpuSpeed = value; }
}
public string os
{
get { return this._operatingSystem; }
set { this._operatingSystem = value; }
}
public string[] cla
{
get { return this._clArray; }
set { this._clArray = value; }
}
}
}
private string[] _clArray = new string[5];
public string[] cla
{
get { return this._clArray; }
set { this._clArray = value; }
}
But within my main form I don't know how to actually use the object to fill the array.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Computer_Specs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string nl = Environment.NewLine;
Computer specs = new Computer();
tbLog.Text = specs.brand = tbBrand.Text + nl;
tbLog.Text = tbLog.Text + (specs.ram = int.Parse(tbRAM.Text)) + nl;
tbLog.Text = tbLog.Text + (specs.cpuBrand = tbcpuBrand.Text) + nl;
tbLog.Text = tbLog.Text + (specs.cpuSpeed = float.Parse(tbCPUSpeed.Text)) + nl;
tbLog.Text = tbLog.Text + (specs.os = tbOS.Text) + nl;
}
}
}
|
|
|
|
|
List<string> claData = new List<string>();
claData.Add("Test1");
claData.Add("Test2");
claData.Add("etc.");
specs.cla = claData.ToArray();
I've just realised that you've initialised your arrays to 5 elements. This probably isn't a good idea. Whatever is using the array probably won't know it has five elements. Were you expecting something to do
specs.clas[0] = "some text" ? In this case, you can access all elements of the array (and change them) from outside the class.
|
|
|
|
|
I tested it and it worked!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Computer_Specs
{
class Computer
{
private string _Brand;
private int _RAM;
private string _cpuBrand;
private float _cpuSpeed;
private string _operatingSystem;
private string[] _clArray;
public string brand
{
get { return this._Brand; }
set { this._Brand = value; }
}
public int ram
{
get { return this._RAM; }
set { this._RAM = value; }
}
public string cpuBrand
{
get { return this._cpuBrand; }
set { this._cpuBrand = value; }
}
public float cpuSpeed
{
get { return this._cpuSpeed; }
set { this._cpuSpeed = value; }
}
public string os
{
get { return this._operatingSystem; }
set { this._operatingSystem = value; }
}
public string[] cla
{
get { return this._clArray; }
set { this._clArray = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Computer_Specs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string nl = Environment.NewLine;
Computer specs = new Computer();
tbLog.Text = specs.brand = tbBrand.Text + nl;
tbLog.Text = tbLog.Text + (specs.ram = int.Parse(tbRAM.Text)) + nl;
tbLog.Text = tbLog.Text + (specs.cpuBrand = tbcpuBrand.Text) + nl;
tbLog.Text = tbLog.Text + (specs.cpuSpeed = float.Parse(tbCPUSpeed.Text)) + nl;
tbLog.Text = tbLog.Text + (specs.os = tbOS.Text) + nl + nl;
List<string> claData = new List<string>();
int loopY = 0;
while (loopY < 5)
{
claData.Add(loopY.ToString());
loopY++;
} specs.cla = claData.ToArray();
int loopX = 0;
while (loopX < 5)
{
tbLog.Text = tbLog.Text + specs.cla[loopX] + nl;
loopX++;
}
}
}
}
My output meaning it was successful.
Dell
2
AMD
2.61
Windows XP
0
1
2
3
4
Where can I start or what would be the next thing I can move onto with classes to help broaden what I have accomplished?
modified on Friday, July 29, 2011 4:48 PM
|
|
|
|
|
Your class looks pretty good, here are some suggestions to tighten it up:
string[] _clArray;
Don't have members with typenames, this should be _cl (or _cla if the a means something other than array). For one thing it is redundant, secondly it is against naming conventions, thirdly names should be meaningful (using array might make sense in an type classing a solar panel array for example). The Microsoft guidance is not to prefix fields (with "_" for example), but I (and most of the people I know do this, as it is internal other devs won't see it (unless reading your code directly).
You should consider:
public string[] Cla
{
get { return this._clArray; }
private set { this._clArray = value; }
}
private prevents the array instance being changed from outide the class. It does lead to problems filling the array, you can do this with the class's constructor or with a specific array-setting method. Personally I'd go for the generic List<string> mentioned earlier by membernnnnnnn. With this you just create the instance inside the object and then can call the it's add method from the get accesssor. Under various circumstances you might want to make the list totally immutable from outside the class, to do this you should get rid of the public accessor you have and look at collection as readonly[^], you can then add Add and Remove methods etc that perform some validation for example.
Note also Cla your class breaks the normal .net naming conventions, you should try to keep to these: the Microsoft classes are written this way and you will confuse other devs using your code by not doing this.
|
|
|
|