When executing a stored procedure in a web service running in .net 2.0 i get the following error
No mapping exists from object type System.RuntimeType to a known managed provider native type
Running the same web service in 1.1 results in a success.
i think its a .net framework bug

Strange Error when executing a stored procedure
DLG007
here is the code im using to execute the stored proc
SqlConnection
__sql=Connect(); SqlCommand __cmd = new SqlCommand("AddCompany",__sql);__cmd.CommandType=
CommandType.StoredProcedure; SqlParameter __name=new SqlParameter("@name",typeof(System.String));__name.Value=name;
__cmd.Parameters.Add(__name);
SqlParameter __email=new SqlParameter("@email",typeof(System.String));__email.Value=email;
__cmd.Parameters.Add(__email);
SqlParameter __password=new SqlParameter("@password",typeof(System.String));__password.Value=password;
__cmd.Parameters.Add(__password);
SqlParameter __statusid=new SqlParameter("@statusid",typeof(System.Int32));__statusid.Value=1;
__cmd.Parameters.Add(__statusid);
SqlParameter __ip=new SqlParameter("@ip",typeof(System.String));__ip.Value=ip;
__cmd.Parameters.Add(__ip);
SqlParameter __companyinfo=new SqlParameter("@companyinfo",typeof(System.String));__companyinfo.Value=companyinfo;
__cmd.Parameters.Add(__companyinfo);
SqlParameter __companykey=new SqlParameter("@companykey",typeof(System.String)); string __key=""; while(__key.Length<32){
__key+=Practisoft.Common.Secure.
Utility.RandomCharacter();}
__companykey.Value=__key;
__cmd.Parameters.Add(__companykey);
SqlParameter __publickey=new SqlParameter("@publickey",typeof(System.String));__publickey.Value=publickey;
__cmd.Parameters.Add(__publickey);
SqlParameter __clienttype=new SqlParameter("@clienttype",typeof(System.String));__clienttype.Value=clienttype;
__cmd.Parameters.Add(__clienttype);
SqlParameter __clientinstance=new SqlParameter("@clientinstance",typeof(System.String));__clientinstance.Value=clientinstance;
__cmd.Parameters.Add(__clientinstance);
SqlParameter __companyid=new SqlParameter("@companyid",typeof(System.Int32));__companyid.Direction=
ParameterDirection.InputOutput;__cmd.Parameters.Add(__companyid);
__cmd.ExecuteNonQuery();
its on the execute query line that fails
here is the full error
No mapping exists from object type System.RuntimeType to a known managed provider native type. at System.Data.SqlClient.MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen)
at System.Data.SqlClient.SqlParameter.GetMetaTypeOnly()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at PractiLicencingService.PractiLicencingDB.AddCompany(String publickey, String clienttype, String clientinstance, String name, String email, String password, String ip, String companyinfo)
at PractiLicencingService.PractiLicencingService.AddCompany(NameValueCollection[] nvc) at PractiLicencingService.PractiLicencingService.AddCompany(NameValueCollection[] nvc)Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Practisoft.Common.Secure.EncryptedWebService.Message(String mykey, String data)An exception occurred at Practisoft.Common.Secure.EncryptedWebService.Message(String mykey, String data)
Reza Bemanian
the stored proc simply inserts a record using the passed values..
I have taken the values used in the instance of failure and executed it in query analyzer with success.
the code i am using is the same style of stored proc executing i have used throughout all my applications with no such problems in the past.
I have a feeling its to do with my setup.
SQL 2005 Express
Visual Studio 2005,
Vista
IIS
Using a sql connection string with a sql user
nikos_22
never seen that before but thats just me having not worked with ASP.NET webservices alot.
Can you post the code you are using and where the exception is thrown from Also what does the SPROC do
Surit Roy
:-)
instead of using typeof(), why dont you use the SqlDbType I'm sure this is the reason for it as it may not be able to find the right type to use as the field in SQL Server. So replace typeof() with the correct SqlDbType enum, as well as giving the length too. Example:
SqlParameter __name=new SqlParameter("@name",SqlDbType.TypeHere, Length);
Fantonis
That seems to have curred it.. strange tho seing as it works in 1.1.. oh well everydays a school day
thanks for the tip off