ObjectDatasource and tableAdapter - Parameters do not match to the method signature [Resharper 6.0][build 2160.226)

 

Hi there,

Solution Analyzer seems to think there is a problem with "Parameters do not match to the method signature", it's an objectdatasource that is hooked up to a tableadapter that generates the crud methods for me
with the following (I've marked them in red), the delete method seems to be fine. In reshaper 5.1.3 this is not an error


<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
     DeleteMethod="Delete" InsertMethod="Insert" 
     OldValuesParameterFormatString="original_{0}" SelectMethod="GetTasksByUserId" 
     TypeName="TaskDataSetTableAdapters.Employee_TaskTableAdapter" 
     UpdateMethod="Update">
     <DeleteParameters>
          <asp:Parameter Name="Original_TaskID" Type="Int32" />
     </DeleteParameters>
     <InsertParameters>
          <asp:ControlParameter ControlID="hfUserId" DbType="Guid" Name="userId" PropertyName="Value" />
          <asp:Parameter Name="Name" Type="String" />
          <asp:Parameter Name="Due" Type="DateTime" />
          <asp:Parameter Name="Complete" Type="Boolean" />
     </InsertParameters>
     <SelectParameters>
          <asp:ControlParameter ControlID="hfUserId" DbType="Guid" Name="userId" PropertyName="Value" />
     </SelectParameters>
     <UpdateParameters>
          <asp:ControlParameter ControlID="hfUserId" DbType="Guid" Name="userId" PropertyName="Value" />
          <asp:Parameter Name="Name" Type="String" />
          <asp:Parameter Name="Due" Type="DateTime" />
          <asp:Parameter Name="Complete" Type="Boolean" />
          <asp:Parameter Name="Original_TaskID" Type="Int32" />        
     </UpdateParameters>
</asp:ObjectDataSource>


Below are the generated TableAdapter methods

DELETE
 [DataObjectMethod(DataObjectMethodType.Delete, true)]
    [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
    [DebuggerNonUserCode]
    [HelpKeyword("vs.data.TableAdapter")]
    public virtual int Delete(int Original_TaskID)
    {
      this.Adapter.DeleteCommand.Parameters[0].Value = (object) Original_TaskID;
      ConnectionState state = this.Adapter.DeleteCommand.Connection.State;
      if ((this.Adapter.DeleteCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
        this.Adapter.DeleteCommand.Connection.Open();
      try
      {
        return this.Adapter.DeleteCommand.ExecuteNonQuery();
      }
      finally
      {
        if (state == ConnectionState.Closed)
          this.Adapter.DeleteCommand.Connection.Close();
      }
    }


INSERT
 [DataObjectMethod(DataObjectMethodType.Insert, 
true)]
    [DebuggerNonUserCode]
    [HelpKeyword("vs.data.TableAdapter")]
    [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
    public virtual int Insert(Guid UserId, string Name, DateTime? Due, bool Complete)
    {
      this.Adapter.InsertCommand.Parameters[0].Value = (object) UserId;
      if (Name == null)
        throw new ArgumentNullException("Name");
      this.Adapter.InsertCommand.Parameters[1].Value = (object) Name;
      if (Due.HasValue)
        this.Adapter.InsertCommand.Parameters[2].Value = (object) Due.Value;
      else
        this.Adapter.InsertCommand.Parameters[2].Value = (object) DBNull.Value;
      this.Adapter.InsertCommand.Parameters[3].Value = (object) (bool) (Complete ? 1 : 0);
      ConnectionState state = this.Adapter.InsertCommand.Connection.State;
      if ((this.Adapter.InsertCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
        this.Adapter.InsertCommand.Connection.Open();
      try
      {
        return this.Adapter.InsertCommand.ExecuteNonQuery();
      }
      finally
      {
        if (state == ConnectionState.Closed)
          this.Adapter.InsertCommand.Connection.Close();
      }
    }
UPDATE 
    [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
    [DebuggerNonUserCode]
    [HelpKeyword("vs.data.TableAdapter")]
    [DataObjectMethod(DataObjectMethodType.Update, true)]
    public virtual int Update(Guid UserId, string Name, DateTime? Due, bool Complete, int Original_TaskID)
    {
      this.Adapter.UpdateCommand.Parameters[0].Value = (object) UserId;
      if (Name == null)
        throw new ArgumentNullException("Name");
      this.Adapter.UpdateCommand.Parameters[1].Value = (object) Name;
      if (Due.HasValue)
        this.Adapter.UpdateCommand.Parameters[2].Value = (object) Due.Value;
      else
        this.Adapter.UpdateCommand.Parameters[2].Value = (object) DBNull.Value;
      this.Adapter.UpdateCommand.Parameters[3].Value = (object) (bool) (Complete ? 1 : 0);
      this.Adapter.UpdateCommand.Parameters[4].Value = (object) Original_TaskID;
      ConnectionState state = this.Adapter.UpdateCommand.Connection.State;
      if ((this.Adapter.UpdateCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
        this.Adapter.UpdateCommand.Connection.Open();
      try
      {
        return this.Adapter.UpdateCommand.ExecuteNonQuery();
      }
      finally
      {
        if (state == ConnectionState.Closed)
          this.Adapter.UpdateCommand.Connection.Close();
      }
    }


The only thing I can think of is that one parameter is nullable and that it might be causing the error?

Thanks for your time and effort
11 comments

We are seeing the same error in some very similar code. R# 6.0.2202.688 in VS 2010 as well as .NET inspections runner in TeamCity 7.0 EAP build 20334.

0

I'm running into the same behavior. Using R# 6.1.1000.82.

Did this post ever make it into a bug report?

0

http://youtrack.jetbrains.com/issue/RSRP-284259

It does not appear to be released yet. The current official R# build is 7.0.1098.2760 and the issue is marked fixed in 7.0.1098.2791.

0

Hi everyone,

Please try out ReSharper 7.1 EAP to see if this issue is fixed for you: http://confluence.jetbrains.net/display/ReSharper/ReSharper+7.1+Nightly+Builds.
Please let me know the results.

Thanks!

0

I've tried 7.1 Nightly Build #5 on VS2010SP1. I still get the same error.

With 7.0 or 7.1 I even get a new error (as compared to 6.1).
On my <asp:BoundField> definitions inside my <asp:DetailsView> R# now shows "Cannot resolve symbol 'ShipperID' on the DataField.

<asp:BoundField DataField="ShipperID" HeaderText="ShipperId" ReadOnly="True" InsertVisible="False"/>

The symbol doesn't have a red squigly line but its color is red in stead of blue. When I hover over the symbol R# does show the error.
It's an interesting error, as R# doesn't know which DataFields exist. The SelectMethod's return type is DataTable, so R# can't know which columns it will contain.

This (incorrect) error only appears when I have the InsertMethod defined inside the ObjectDataSource. If I delete the InsertMethod, both errors disappear.

0

Dick, thanks for the feedback. Unfortunately, I can't reproduce such behavior on the latest R# 7.1 nightly. Is it possible to strip down your working solution to a smaller one and send it to us? Am I right that you're working on a plain ASP WebForms site?
Thanks in advance!

Kirill Falk
.NET Team QA Lead
JetBrains Inc,

0

Maybe my situation isn't exacly the same as the original post. I'm just using an ObjectDataSource connecting to my own business object.
My project is just a standard ASP.NET Web Application project (not a Web Site).

I'm using Visual Studio 2010 Ultimate Version 10.0.40219.1 SP1Rel with JetBrains ReSharper 7.1 EAP Full Edition Build 7.1.5.2.

The attached solution gives me the error "Parameters do not match to the method signature" when viewing Default.aspx. You can just run it to see the InsertMethod works just fine. I'm using Debug.WriteLine to write to the Ouput window.

To see the other error (Cannot resolve symbol 'ShipperId'), change the SelectMethod of ShipperDataSource from GetAllShippersList to GetAllShippersDataTable. But in hinsight, maybe the error makes sense. Method GetAllShippersDataTable is returning an untyped DataTable, so ReSharper can't know which properties exist. It's a bit strange though that ReSharper doesn't see a problem with BoundField "ShipperName". I suppose this is because the InsertParameters tag contains a Parameter called "shipperName".
So ReSharper is right about being unable to resolve the symbol. But in this case, that isn't an error. I can imagine if this is very hard to fix. If the ObjectDataSource's SelectMethod is returning an actual object (like method GetAllShippersList), it would be an error if a DataField can't be found in the return type.

One other things I noticed: ReSharper is warning me about a Redundant 'String.Format()' call on the Debug.WriteLine inside method InsertShipper. The String.Format is not redundant there. Because the variable shipperName is a string, the call to Debug.WriteLine will end up with two strings. That signature is another overload of Debug.WriteLine, meaning string message, string category.



Attachment(s):
ParametersDoNotMatch.zip
0

Great, Dick. Thank you very much for the sample. We will try to reproduce it tomorrow morning and fix it ASAP. Feel free to mail me directly via Kirill.Falk@jetbrains.com with any questions and issues.

Kirill Falk
.NET Team QA Lead
JetBrains, Inc

0

The problem still exists in build 7.1.8.128. I suppose you didn't have time yet to dive into the problem.

For the incorect suggestion on removing String.Format, I've created a bug report.

0

Hi,

The problem with ObjectDataSource is fixed in the latest R# 7.1 nightly build.

Kirill Falk
.NET Team QA Lead

0

I don't have the problem with ObjectDataSource anymore using EAP build 7.1.16.12.

0

Please sign in to leave a comment.