I have a Blazor Web Assembly project that I started in .NET5. I am using Blazorise and it is working well for me.
A few weeks ago, I upgraded to .NET6, initially within the main project and found that I was getting a strange error.
Shortly after loading the index page, after some back and forth to the server getting user details etc. I am getting an unhandled exception with a bunch of console messages which don't really indicate (to me) where the error is...
I have used an image to condense the messages. I can make the detail available if needed. I have followed some of the links and they take me deep into JS territory.
The strange things about this are:
a) This didn't occur till I updated to NET6 - initially I thought it could be that I had updated wrongly, so I rebuilt the App from the ground up using a NET6 Template. The error came back.
b) I have spent days using a process of elimination to be able to make the error 'go away' - details follow:
I have several components I am using for forms:
-an EditUserForm
-an OrgansationForm
-an AddressForm
They are all components and use Blazorise Modals. Here is the EditUserForm:
#namespace blah.Client.Components.Forms
<Modal #ref="modalRef">
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>Editing #editUser.FullName</ModalTitle>
<CloseButton Clicked="#HideModal" />
</ModalHeader>
<ModalBody MaxHeight="50">
<div class="bg-light">
#if (editUser.IsComplete)
{
<p>Your Information is Complete - Make any changes and Press the 'Save' button.</p>
}
else
{
<p>Your Information is Incomplete - Please ensure you have completed at least your Name, Address, Mobile Number and Gender.</p>
}
</div>
<EditForm Model="#editUser" #onchange="() => Refresh()">
<DataAnnotationsValidator />
<Field>
<FieldLabel>Title</FieldLabel>
<TextEdit Placeholder="Enter Title..." #bind-Text="#editUser.Title" />
</Field>
<Field>
<FieldLabel>First Name</FieldLabel>
<TextEdit Placeholder="Enter First Name..." #bind-Text="#editUser.FirstName" />
</Field>
<Field>
<FieldLabel>Middle Name</FieldLabel>
<TextEdit Placeholder="Enter Middle Name..." #bind-Text="#editUser.MiddleName" />
</Field>
<Field>
<FieldLabel>Last Name</FieldLabel>
<TextEdit Placeholder="Enter Last Name..." #bind-Text="#editUser.FamilyName" />
</Field>
<Field>
<FieldLabel>Email</FieldLabel>
<TextEdit Placeholder="Enter Email..." #bind-Text="#editUser.Email" />
</Field>
<Field>
<FieldLabel>Phone No</FieldLabel>
<TextEdit Placeholder="Enter Phone No..." #bind-Text="#editUser.PhoneNumber" />
</Field>
<Field>
<FieldLabel>Date of Birth</FieldLabel>
<InputDate #bind-Value="#editUser.DoB" />
</Field>
<Field>
<FieldLabel>Gender</FieldLabel>
<Blazorise.Select TValue="AvailablePlayer.Shared.Enums.Gender" #bind-SelectedValue="#editUser.Gender">
#foreach (AvailablePlayer.Shared.Enums.Gender gendertype in Enum.GetValues(typeof(AvailablePlayer.Shared.Enums.Gender)))
{
var gtypetemp = gendertype;
<Blazorise.SelectItem Value="#gtypetemp">
#Enum.GetName(typeof(AvailablePlayer.Shared.Enums.Gender), gtypetemp).Replace('_', ' ');
</Blazorise.SelectItem>
}
</Blazorise.Select>
</Field>
<Field>
<FieldLabel>Address</FieldLabel>
<div>#getlongaddress()</div>
#if (editUser.Address != null && !editUser.Address.IsComplete)
{
<p>The Address is incomplete, please edit</p>
<Button Color="Color.Danger" Clicked="#EditAddress">Edit Address</Button>
}
else
{
<Button Color="Color.Secondary" Clicked="#EditAddress">Edit Address</Button>
}
</Field>
<Field>
<FieldLabel>Sign up as Player and Accept Player T's & C's</FieldLabel>
<InputCheckbox #bind-Value="Isplayer">Accept Player Terms which you can see here</InputCheckbox>
</Field>
#if (Isplayer)
{
<Button Color="Color.Secondary" Clicked="#EditPlayer">Edit Player</Button>
}
<Field>
<FieldLabel>Sign up as a member of an organisation and Accept Member T's & C's</FieldLabel>
<InputCheckbox #bind-Value="Ismember">Accept Member Terms </InputCheckbox>
which you can see here
</Field>
#if (Ismember)
{
<Button Color="Color.Secondary" Clicked="#EditOrgMember">Edit Membership</Button>
}
</EditForm>
<AuthorizeView Roles="Administrator">
<Authorized Context="Auth">
<div class="bg-light">
<p>(Note: to remove Player Role also untick the 'Accept Player Terms' Box)</p>
#foreach (rolebool rolething in rolelist)
{
<div>
<Check TValue="bool" #bind-Checked="rolething.userisin">#rolething.role </Check>
</div>
}
</div>
</Authorized>
</AuthorizeView>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="#HideModal">Close</Button>
<Button Color="Color.Primary" Clicked="#SaveAsync">Save Changes</Button>
</ModalFooter>
</ModalContent>
</Modal>
<CascadingValue Name="EditAddress" Value="#editUser.Address">
<AddressForm #ref="addressform" OnAddressSaved="AddressSaved"></AddressForm>
</CascadingValue>
<EditPlayerForm #ref="playereditform" OnPlayerSaved="Refresh" />
<OrganisationForm #ref="organisationForm" />
<Snackbar #ref="snackbar">
<SnackbarBody>
#StatusMessage
</SnackbarBody>
</Snackbar>
The code is in a seperate file and has many functions, so for brevity I just show the basics here:
namespace blah.Client.Components.Forms
{
public partial class EditUserForm : ComponentBase
{
[Inject] UserService UserService { get; set; }
...some stuff...
//private bool _ismember;
protected bool Ismember;
AddressForm addressform = new AddressForm();
EditPlayerForm playereditform = new EditPlayerForm();
OrganisationForm organisationForm = new OrganisationForm();
...some stuff...
protected void EditAddress()
{
addressform.ShowModal();
}
private void AddressSaved(AddressDTO address)
{
editUser.Address = address;
this.StateHasChanged(); // To reload the address.
}
public void Refresh()
{
this.StateHasChanged();
}
}
This is the OrganisationForm:
#namespace blah.Client.Components.Forms
<Modal #ref="modalRef">
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>Editing Organisation</ModalTitle>
<CloseButton Clicked="#HideModal" />
</ModalHeader>
<ModalBody MaxHeight="50">
<EditForm Model="#editOrganisation" #onchange="() => Refresh()">
<DataAnnotationsValidator />
<Field>
<FieldLabel>Organisation Name</FieldLabel>
<TextEdit Placeholder="blah..." #bind-Text="#editOrganisation.Name" />
</Field>
<Field>
<FieldLabel>Business Address</FieldLabel>
<div>#getlongaddress(editOrganisation.BusinessAddress)</div>
#if (editOrganisation.BusinessAddress != null && !editOrganisation.BusinessAddress.IsComplete)
{
<p>The Address is incomplete, please edit</p>
<Button Color="Color.Danger" Clicked="() => EditAddress(editOrganisation.BusinessAddress)">Edit Main Address</Button>
}
else
{
<Button Color="Color.Secondary" Clicked="() => EditAddress(editOrganisation.BusinessAddress)">Edit Main Address</Button>
}
</Field>
<Field>
<FieldLabel>Date Joined</FieldLabel>
<DateEdit #bind-Date="editOrganisation.DateJoined" />
</Field>
</EditForm>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="#HideModal">Close</Button>
<Button Color="Color.Primary" Clicked="#SaveAsync">Save</Button>
</ModalFooter>
</ModalContent>
</Modal>
<AddressForm #ref="addressform" OnAddressSaved="AddressSaved"></AddressForm>
<Snackbar #ref="snackbar">
<SnackbarBody>
#StatusMessage
</SnackbarBody>
</Snackbar>
...and the code for the OrganisationForm (with some functions removed)
namespace blah.Client.Components.Forms
{
public partial class OrganisationForm : ComponentBase
{
[Inject] ExecService ExecService { get; set; }
// reference to the modal component
protected Modal modalRef = new Modal();
AddressForm addressform = new AddressForm();
DatePicker<DateTime?> datepicker = new DatePicker<DateTime?>();
[Parameter]
public EventCallback<OrganisationDTO> OnOrganisationSaved { get; set; }
public OrganisationDTO editOrganisation { get; set; } = new OrganisationDTO();
private void AddressSaved(AddressDTO address)
{
editOrganisation.BusinessAddress = address;
this.StateHasChanged(); // To reload the address.
}
protected void EditAddress(AddressDTO addresstoedit)
{
addressform.editAddress = addresstoedit;
addressform.ShowModal();
}
protected async Task SaveAsync()
{
editOrganisation = await ExecService.AddUpdateOrganisationAsync(editOrganisation);
StatusMessage = editOrganisation.Status.Reason;
await snackbar.Show();
HideModal();
await OnOrganisationSaved.InvokeAsync(editOrganisation);
}
}
}
and finally the AddressForm:
#namespace blah.Client.Components.Forms
<Modal #ref="modalRef">
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>Editing Address</ModalTitle>
<CloseButton Clicked="#HideModal" />
</ModalHeader>
<ModalBody MaxHeight="50">
<div class="bg-light">
#if (editAddress.IsComplete)
{
<p>Your Address is Complete - Make any changes and Press the 'Save' button.</p>
}
else
{
<p>Your Address is Incomplete - Please ensure you have at least your Number, Street and PostCode.</p>
}
</div>
<EditForm Model="#editAddress" #onchange="() => checkaddress()">
<DataAnnotationsValidator />
<Field>
<FieldLabel>No. Name or Building</FieldLabel>
<TextEdit Placeholder="Enter House No, Name Building..." #bind-Text="#editAddress.Line1"/>
</Field>
<Field>
<FieldLabel>Street</FieldLabel>
<TextEdit Placeholder="Enter Street..." #bind-Text="#editAddress.Line2" />
</Field>
<Field>
<FieldLabel>Town/City</FieldLabel>
<TextEdit Placeholder="Enter Town/City..." #bind-Text="#editAddress.Line3" />
</Field>
<Field>
<FieldLabel>Region/State</FieldLabel>
<TextEdit Placeholder="Enter Region/State..." #bind-Text="#editAddress.Line4" />
</Field>
<Field>
<FieldLabel>Post Code</FieldLabel>
<TextEdit Placeholder="Enter Post Code..." #bind-Text="#editAddress.PostCode" />
</Field>
</EditForm>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="#HideModal">Close</Button>
<Button Color="Color.Primary" Clicked="#SaveAsync">Save</Button>
</ModalFooter>
</ModalContent>
</Modal>
... and the AddressForm code:
namespace blah.Client.Components.Forms
{
public partial class AddressForm : ComponentBase
{
// reference to the modal component
protected Modal add_modal = new Modal();
[CascadingParameter(Name = "EditAddress")]
AddressDTO editAddress { get; set; } = new AddressDTO();
[Parameter]
public EventCallback<AddressDTO> OnAddressSaved { get; set; }
// Since this is going to be usually called from another form feed back the address
// by way of this event.
async Task SaveAsync()
{
await OnAddressSaved.InvokeAsync(editAddress);
await add_modal.Hide();
}
// Display functions
public void ShowModal()
{
add_modal.Show();
}
public void HideModal()
{
add_modal.Hide();
}
public void checkaddress()
{
this.StateHasChanged();
}
}
}
...
I have tried many things, but I keep coming back to the error message that I don't really understand fully as it looks like something is going on with a null in the JS interop but I'm unclear.
I can make the problem go away by reducing the AddressForm to simply this:
#namespace blah.Client.Components.Forms
<h1>Address Form</h1>
<Modal #ref="add_modal">
<ModalContent IsCentered="true">
<h1>Address Form</h1>
</ModalContent>
</Modal>
err most of the time.. then it has come back, although it is difficult to keep track because the Chrome debugger sometimes caches stuff and I have to remember to refresh with the cache off...
If I remove the '#ref="add_modal"' from the Modal definition it has always worked.
I know this is weird and most of the time there is a clue in the error how to find the problem. This seems to come and go, and feels it might be timing related. The error always takes a few seconds to appear after all the rendering has finished, so its like a short timeout or failed promise in JS type of thing.
I have tried many things but the code hasn't really changed since I upgraded to NET6 (along with the other components). Another possibility would be if I could add an exception handler maybe and break on it or write my own message, however, I am not sure where to put that?
I am looking for some pointers of how to track this down tbh as I am pretty much at wits end. The error may be staring me in the face in the messages, but I don't see it.
Many thanks
Brett
I recently upgraded a blazor project to .net6 and had the same issue. One of my projects was failing to build for no apparent reason saying metadata files were missing. There were no other surface errors. I ended up finding a hidden compiler error in my project that VS was not displaying. Code in .razor files doesn’t seem to be monitored by the IDE unless the file is open. I opened all razor files and like magic the real error appeared in the error window.
I also had console errors from code in updated packages. I looked at the updates made to the packages to see what might cause those. Some functions in packages had been modified and given overloads I needed to switch to and that got rid of my other errors.
If you have a good folder and file structure in your project a fast way to do this is to open all files in a folder that contains razor files and wait a few seconds for errors to pop up. Close them if none pop up and move to the next folder.
There may be multiple errors so keep opening files and resolving errors when they pop up until you have gone through every folder.
It takes a little time For a large project but it’s not that bad.
Related
I'm learning how to use React with .NET and am using the Visual Studio templates provided to play around (I'm using a Mac, if that is useful for context). I am starting with very simple back end applications and trying to get my React front end to link to these. I am very new to using React and .NET so I apologise if the questions I ask seem simple. Here is my current issue:
I have the following C# Controller class which retrieves and returns the middle letters of a string:
MiddleLetterController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace TestingReactDotNet.Controllers
{
public class MiddleLetterController : Controller
{
public string GetMiddle(string word)
{
if (word.Length % 2 == 0)
{
return word.Substring(word.Length / 2 - 1, 2);
}
else
{
return word.Substring(word.Length / 2, 1);
}
}
}
}
I am using React on the front end and want whatever the user types and submits in the form to be the word passed as an argument to the GetMiddle() method and for this to be displayed on screen.
My current MiddleLetter.js file is:
import React, { Component } from "react";
export class MiddleLetter extends Component {
state = {
word: "",
};
updateInput(key, value) {
// update react state
this.setState({
[key]: value
});
}
render() {
return (
<center>
<div className="App">
<div>
Type a word...
<br />
<input
type="text"
placeholder="Type word here ..."
value={this.state.word}
onChange={e => this.updateInput("word", e.target.value)}
/>
<button onClick={() => ?????)}>Submit</button>
<br />
</div>
</div>
</center>
);
}
}
I have looked at the React documentation but cannot work out how / the best way to link the React form submission to the backend application. I would be really grateful if anyone had any suggestions please :) Thank you.
You're probably going to want to pull in a library like axios or fetch into your react project "yarn add axios" in your react folder.
Then at the top of your MiddleLetter.js you'll need to import axios from axios;
create an instance of axios in MiddleLetter.js, something like:
const instance = axios.create({
baseURL: "localhost:{whatever port you're running on}",
)}
Then in your "updateInput" function where your comments are add:
const response = await instance.get("/middleletter/" + value);
your response should have the return value from the controller.
Then for your controller.
add [HttpGet({word})]
over public string GetMiddle(string word)
This will let the controller get the word from your URL.
There are better ways to do all of this. But this should get you where you need to go.
I want to open a PDF on the Phone via the File-Path but i cant figure out how i could do this properly without using 3rd party packages.
You have any suggestion for this?
I already tried to use this on Android:
public void OpenFile(string filePath)
{
var fileToOpen = new Java.IO.File(filePath);
var uri = FileProvider.GetUriForFile(Application.Context, Application.Context.PackageName + ".fileprovider", fileToOpen);
var intent = new Intent();
var mime = IOUtil.GetMimeType(uri.ToString());
intent.SetAction(Intent.ActionView);
intent.SetDataAndType(uri, mime);
intent.SetFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
Application.Context.StartActivity(intent);
}
But i get the following Error:
Unhandled Exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method
'android.content.res.XmlResourceParser
android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,
java.lang.String)' on a null object reference
first you should addd this code to your manifest file :
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.easyphotopicker.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/filepaths"
tools:replace="android:resource"/>
</provider>
and create filepaths :
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<root-path name="root" path="" /> //root directory of the device new File("/");
<files-path name="files" path="" /> //context.getFilesDir()
<cache-path name="cache" path="" /> //context.getCacheDir()
<external-path name="external" path="" /> //Environment.getExternalStorageDirectory()
<external-files-path name="name" path="path" /> //context.getExternalFilesDirs()
<external-cache-path name="name" path="path" /> //getExternalCacheDirs()
</paths>
Your error is telling us that there is no file at the location matching that's passed into the function. There's a few ways of doing this, one of them is as shown. After accepting permissions to access folders and files, this should be one of the simplest ways. You seem to be close:
public void OpenPdfFile(string filename)
{
var f = new Java.IO.File(filename);
if (f.Exists())
{
System.Diagnostics.Debug.WriteLine("File exists!");
try
{
var openFileIntent = new Intent(Intent.ActionView);
openFileIntent.SetDataAndType(Android.Net.Uri.FromFile(f), "application/pdf");
openFileIntent.SetFlags(ActivityFlags.NoHistory);
StartActivity(Intent.CreateChooser(openFileIntent, "Open pdf file"));
}
catch (ActivityNotFoundException)
{
//handle when no available apps
}
}
}
I haven't tested your work, but the first thing would be to see if you added this to the Manifest file
android:authorities="com.{package}.{name}.fileprovider"
since your code says Application.Context.PackageName + ".fileprovider"
here is my code
regXmppClient.SetUsername("abcd");
regXmppClient.SetXmppDomain("abcd.com");
regXmppClient.Password = "abcd";
regXmppClient.RegisterNewAccount = true;
regXmppClient.Open();
regXmppClient.OnRegister += new EventHandler<Matrix.EventArgs>(xmppCon_OnRegister);
regXmppClient.OnRegisterInformation +=
new EventHandler<Matrix.Xmpp.Register.RegisterEventArgs>(xmppCon_OnRegisterInformation);
regXmppClient.OnRegisterError += new EventHandler<Matrix.Xmpp.Client.IqEventArgs>(xmppCon_OnRegisterError);
XMl Error log
<iq type="error" id="MX_2" from="abcd.com" to="abcd.com/55ce2afc" xmlns="jabber:client">
<query xmlns="jabber:iq:register">
<username>abcd</username>
<password>abcd</password>
<email />
<name />
<x xmlns="jabber:x:data" type="form">
<title>XMPP Client Registration</title>
<instructions>Please provide the following information</instructions>
<field var="FORM_TYPE" type="hidden">
<value>jabber:iq:register</value>
</field>
<field var="username" type="text-single" label="Username">
<required />
</field>
<field var="name" type="text-single" label="Full name" />
<field var="email" type="text-single" label="Email" />
<field var="password" type="text-private" label="Password">
<required />
</field>
</x>
</query>
<error code="400" type="modify">
<jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
</error>
</iq>
I got solution finally, I can Register new account using XmppClientConnection
_xmppConnection.Server = SERVER_NAME;
_xmppConnection.ConnectServer = SERVER_NAME;
_xmppConnection.Username = objxmppData.UserName;
_xmppConnection.Password = objxmppData.password;
**_xmppConnection.RegisterAccount = true;**
_xmppConnection.Open();
_xmppConnection.OnAuthError += loginFailed;
_xmppConnection.OnLogin += new ObjectHandler(xmpp_OnLogin);
As in above code make RegisterAccount = true will do both create new account and loggedin with the same.
you code submits a xdata from and the old jabber style fields , , and . Some servers have problems with that, and I guess they are right.
If you want to use old jabber style registration then remove the xdata from in your set query. If you want to use xdata then remove the old jabber style fields.
see also: http://forum.ag-software.net/thread/874-How-to-Register-a-new-Account-on-an-xmpp-server
I am creating a MSI based Installer using Wix.
My Custom Action declaration goes like this...
<Binary Id="CustomActions" SourceFile="DLLs\CustomActions.CA.dll" />
<CustomAction Id="CheckPath" Return="check" Execute="immediate" BinaryKey="CustomActions" DllEntry="CheckPath" />
And under WixUI_InstallDir Dialog UI,
<UI Id="WixUI_InstallDir">
.....
<Publish Dialog="SelectDirDlg" Control="Next" Event="DoAction" Value="CheckPath" Order="2">1</Publish>
.....
</UI>
And in C# file,
[CustomAction]
public static ActionResult CheckPath(Session session)
{
Record record2 = new Record();
record.FormatString = "The path that you have selected is invalid!";
session.Message(InstallMessage.Error | (InstallMessage)MessageButtons.OK, record);
return ActionResult.Success;
}
I am expecting a Message box via the above Custom Action when the user selects an invalid path. But the message box is not shown.
What am I doing wrong?
Custom actions triggered via a DoAction control event cannot show message boxes. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa368322%28v=vs.85%29.aspx.
I have gotten to the point where SolrNet executes the "Add" method but when I try to "Commit" is when I receive the error. The following is my schema.xml, model, code calling it, and the error I get. Even stranger is that despite the error, the model is added to my Solr index AFTER I restart Tomcat (so it still adds my model despite the error but not immediately):
schema.xml (fields and fieldtypes):
<!-- Fields -->
<field name="part_numbers" type="my_string_exact" indexed="true" stored="true" multiValued="true" />
<field name="page_url" type="my_string_exact" indexed="true" stored="true" />
<field name="product_name" type="my_string" indexed="true" stored="true" />
<!-- FieldTypes -->
<fieldType name="my_string_exact" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="my_string" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
<fieldType name="my_int" class="solr.IntField" omitNorms="true" />
Model (Product.cs) *NOTE - PageId uses the Solr default "id" that is a string, unique and required:
public class Product
{
[SolrUniqueKey("id")]
public string PageId { get; set; }
[SolrField("part_numbers")]
public ICollection<string> PartNumbers { get; set; }
[SolrField("page_url")]
public string PageUrl { get; set; }
[SolrField("product_name")]
public string Name { get; set; }
}
Code initializing, calling the Add and Commit *NOTE - This is a unit test so init is only called once:
Startup.Init<Product>("http://localhost:8080/solr");
Product testProd = new Product() {
EPiPageId = "44",
Name = "TestProd3",
PageUrl = "/TestProd3",
PartNumbers = new List<string>() { "000022222", "000000333333" }
};
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
solr.Add(testProd);
solr.Commit(); // Bad Request Error occurs here.
Error Msg:
SolrNet.Exceptions.SolrConnectionException was unhandled by user code
HResult=-2146232832
Message=The remote server returned an error: (400) Bad Request.
Source=SolrNet
StackTrace:
at SolrNet.Impl.SolrConnection.Post(String relativeUrl, String s) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 104
at SolrNet.Commands.CommitCommand.Execute(ISolrConnection connection) in c:\prg\SolrNet\svn\SolrNet\Commands\CommitCommand.cs:line 71
at SolrNet.Impl.SolrBasicServer`1.Send(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 87
at SolrNet.Impl.SolrBasicServer`1.SendAndParseHeader(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 91
at SolrNet.Impl.SolrBasicServer`1.Commit(CommitOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 54
at SolrNet.Impl.SolrServer`1.Commit() in c:\prg\SolrNet\svn\SolrNet\Impl\SolrServer.cs:line 24
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse() in c:\prg\SolrNet\svn\HttpWebAdapters\Impl\HttpWebRequestAdapter.cs:line 36
at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 160
at SolrNet.Impl.SolrConnection.Post(String relativeUrl, String s) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 101
InnerException:
EDIT Thanks to Paige for the answer: The issue was a "waitFlush" error that is a bug with older versions of SolrNet. The version of SolrNet that I was using was from VS NuGet that was 0.3.1 (which I assumed was their latest stable build). Their google code site does not have their most recent build but the build server (here: http://teamcity.codebetter.com/project.html?projectId=project36&guest=1 under "artifacts") did have the latest with the fix to this bug. Problem solved for me.
I am guessing that you are probably seeing a waitFlush error in your Tomcat Logs and you are using version 4.X of Solr. If that is the case, this is a known issue with Solr 4.x and older versions of SolrNet. To fix this issue, upgrade to a later release of the SolrNet library. You can download it from the Build Server. Click on Artifacts to get a link to the zip.