|
i have a page in a web service:'default.asmx'
in default.cs(in App_Code) is a web method:
[WebMethod]
public string zakhire(string s,string d)
{
string sql = " insert into FX_Forecast2 (Symbol,A) values( '"+s+"','"+d+"')";
OpenDb();
cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
return sql;
}
type of fields 'Symbol,A' are nvarchar..
now without knowing about a software that send data to webservice,i run this page in visual studio that test this page.
after running this page and executing the method with my arrival data and press 'invoke' button,a page open and in it's url just is method name:
http:
but i need to parameters and values too.like this:
http:
i had seen in a book that has been written in vb language in visual studio that after executing the method and opening a page,arrival parameters and values been in url with method name.
i hope that explain my need clearly.
totally i have a script in mql language in another software that run this url:
http:
i want to insert this parameters('s' and 'd')in database.
so i build a webservice and wrote in .asmx page that code.
do i think right?
modified on Saturday, January 8, 2011 7:46 AM
|
|
|
|
|
I found the answer:
with Going to web.config and adding this code in system.web section:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
good luck.
|
|
|
|
|
Try to read string from the registry - i get beck null all the time
Code:
public static string ReadStringFromRegistry( string hive, string key )
{
string strRetVal = null;
try
{
using( RegistryKey regKey = Registry.LocalMachine.OpenSubKey( hive ) )
{
if( null != regKey )
{
strRetVal = regKey.GetValue( key ) as string;
if( String.IsNullOrEmpty( strRetVal ) )
{
strRetVal = null;
Debug.Assert( false, "fail to read from the registry" );
}
}
}
}
catch( Exception e )
{
}
return strRetVal;
}
|
|
|
|
|
Your code is working fine for me, so there is nothing wrong with it. You probably have wrong input strings. Please check if "hive" and "key" are correct.
|
|
|
|
|
Thanks,
In the line
strRetVal = regKey.GetValue( key ) as string;
i get strRetVal as null.
|
|
|
|
|
So, what is the value that you expect to read? And of which type is it?
|
|
|
|
|
I read simple string that i created.
If i try to read some other string ( that i did not created ) from the next hive - i see that the result are ok.
Very Strange...
P.S: using win7 - and i check the premmision of the registry access.
|
|
|
|
|
Have you checked in the registry editor if your created string is somehow different from the one you are able to read? (is it of type REG_SZ?) I just tested creating one key and then read it back and it worked fine with XP.
|
|
|
|
|
|
when you swallow exceptions like you do, you deserve the trouble you're getting.
|
|
|
|
|
Dear All,
I am trying to log the methods using Aspect oriented progamming ( AOP) and custom attributes.
Use a class derived from ContextBoundObject with a custom attribute. IMessageSink and IContextProperty are aslo implemented to catch the sink messages. This sample worked fine.
But the problem is the this custom attributes work on class level only( i have already tried AttributeTargets.Method). So all methods will be logged. but i want only selected method by giving the attribute on methods.
Thanks
|
|
|
|
|
i am using below code to extract the files inside the zip folder.
getting an error while using copyHere method ..
after deleteing the folder i m trying to create a new one . and then copying from the zip file
but still it gives an error "File exist"
Please provide a solution thanks in advance
if (Directory.Exists(unzipFilePath))
{
Directory.Delete(unzipFilePath, true);
Directory.CreateDirectory(unzipFilePath);
}
else
{
Directory.CreateDirectory(unzipFilePath);
}
Shell objShell = new Shell();
Folder shellZipFile = objShell.NameSpace(zipFilePath);
Folder shellUnZipFile = objShell.NameSpace(uzipFilePath);
foreach (FolderItem zipFileitem in shellZipFile.Items())
{
shellUnZipFile.CopyHere(zipFileitem, 0);
}
This error is happening in a particular system
|
|
|
|
|
It seems a little confusing even looking at the MSDN documentation: http://msdn.microsoft.com/en-us/library/aa328748(v=VS.71).aspx[^] which says that true will delete files and subdirectories. However, when you look at the example on the same page it says:
'This operation will not be allowed because there are subdirectories.
for the VB example, and
for the C#.
I suggest you write a quick-and-dirty tester to check if the directory deleted exists after the delete, and if so what it contains. I suspect that the VB example may be correct, and you will have to manually delete files and subdirectories.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks for the reply
phiscally i checked the folder it was wmpty
and then i inserted below code in copy..
if (File.Exists(String.Format(@"{0}\{1}",unzipFolderName,zipFileitem.Name)))
{
File.Delete(String.Format(@"{0}\{1}",unzipFolderName, zipFileitem.Name));
}
shellUnZipFile.CopyHere(zipFileitem, 0);
|
|
|
|
|
Don't check using Explorer - check if it still exists after the delete in your code, and before you do anything else. (Remember that windows can have invisible files, and hidden files which won't show up in Explorer).
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I had checked through code, explorer by making files visible and all those stuff..
and one more thing in this specific computer.i tried something manually..
like i right clicked the zip file and selected explore. i got an option to
copy the file But when i paste it paste is not happening.
|
|
|
|
|
Have you checked the folder permissions?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Yes i checkd.. normal settings
|
|
|
|
|
This is managed to unmanaged only!
The C code (simplified) is:
typedef INT SomeTypeArray[128];
void SomeFunction(INT *lpSomeTypeArray);
So SomeFunction can just be passed an int[] as an array is a reference type - no problem.
However, I would prefer to have a struct SomeType and another struct SomeTypeArray .
This code does all this:
public static class NativeMethods
{
[DllImport("some.dll", SetLastError = true)]
public static extern void SomeFunction(
SomeTypeArray lpSomeTypeArray);
}
[StructLayout(LayoutKind.Sequential)]
public struct SomeType
{
private int value;
private SomeType(int value)
{
this.value = value;
}
public static implicit operator SomeType(int value)
{
return new SomeType(value);
}
public static implicit operator int(SomeType someType)
{
return someType.value;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct SomeTypeArray
{
private SomeType[] someTypes;
public SomeTypeArray(params SomeType[] someTypes)
{
if (someTypes == null)
this.someTypes = new SomeType[128];
else if (someTypes.Length == 128)
this.someTypes = someTypes;
else
{
this.someTypes = new SomeType[128];
int counter = 0;
foreach (SomeType someType in someTypes)
{
this.someTypes[counter] = someType;
counter++;
if (counter == this.someTypes.Length)
break;
}
}
}
}
The problem with this is that if SomeTypeArray 's default constructor is called, someTypes will be null and therefore invalid - and being a struct the default constructor can't be overloaded and field initializers outside a constructor are not allowed!
Any workaround for this or a better way of doing it?
|
|
|
|
|
Hi Dave,
I'm more than a bit confused by your code. If you want to pass a struct that contains an array, as in this native fellow:
struct myStruct {
...
int myIntegers[];
...
}
then the native side will prefer the dimension of the array to be known at compile time (so it can work out all the offsets); and the managed side must do special things to smash the array inside the struct, rather than just holding a reference. That is what
[MarshalAs(UnmanagedType.ByValArray, SizeConst=7)]
int[] myIntegers;
would do. However your code seems quite different...
|
|
|
|
|
Hi Luc,
Basically, the function takes a pointer to an array of 128 ints - the size is fixed.
It's ensuring that the array is valid - i.e. not null and has 128 elements that is the problem, and I would also like to represent the array in it's own type (SomeTypeArray ) as per the typedef.
|
|
|
|
|
1.
are you sure about the typedef; I'd expect typedef someDefinition someIdentifier;
2.
I'm still not with you. Could you give a full example of the C side?
|
|
|
|
|
This is the function:
void SomeFunction(INT * lpSomeTypeArray);
This is the typedef:
typedef INT SomeTypeArray[128];
I want to simulate the typedef by creating a struct - SomeTypeArry , and each element would logically be SomeType (a wrapper around int) - enforcing the 128 element size is the main problem.
How does the StructLayoutAttribute work with classes? If I could use a class then I can create my own default constructor - but then passing the class instance would result in the class instance reference being passed rather than the first field (the inner array reference type)? Just thinking out aloud here - need to investigate!
|
|
|
|
|
DaveyM69 wrote: typedef INT SomeTypeArray[128];
there are two unknown types in that statement, so something else needs to be added somewhere.
And I still think such a typedef is invalid.
PS: this would compile:
typedef struct {
int data[128];
} *ptrIntArray;
void SomeFunction(ptrIntArray *lpSomeArray);
|
|
|
|
|
It's straight out of the working header file
|
|
|
|