Affichage des articles dont le libellé est Active questions tagged .net - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged .net - Stack Overflow. Afficher tous les articles

I am recieving the System.InvalidOperationException

I have a voice activated program that is throwing the only error. Its a System.InvalidOperationException I have tried numerous methods and I can not figure out why it is not being corrected.


I am using System.Speech. I have a timer and in the timer, i have it enabled and disabled it from True to False and False to True. Neither of it fixes the issue.



i have declared my Class

SpeechRecognitionEngine startlistening = new SpeechRecognitionEngine();


I have specified my Events



startlistening.SetInputToDefaultAudioDevice();
startlistening.LoadGrammarAsync(new Grammar(new GrammarBuilder(new Choices("alexis"))));
startlistening.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(startlistening_SpeechRecognized);


and then I have placed the command



case "quit listening":
Alexis.SpeakAsync("I will await further commands ");
_recognizer.RecognizeAsyncCancel();
startlistening.RecognizeAsync(RecognizeMode.Multiple);
break;


then i have placed my timer



private void tmrSpeech_Tick(object sender, EventArgs e)
{
if (recTimeOut == 10)
{
_recognizer.RecognizeAsyncCancel();
}
else if (recTimeOut == 11)
{
startlistening.RecognizeAsync(RecognizeMode.Multiple);
tmrSpeech.Stop();
recTimeOut = 0;
}
recTimeOut += 1;
}


I have declared the struct for Start listening



void startlistening_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{

string speech = e.Result.Text;
switch (speech)
{
case "alexis":
startlistening.RecognizeAsyncCancel();
Alexis.SpeakAsync("I am back online");
_recognizer.RecognizeAsync(RecognizeMode.Multiple);
break;
}
}


I am at a loss. I have all references set, as well as the timer set on


Enabled False Interval 10000 GenerateMember True Modifiers Private


Could there be something i am missing. When i tell the program to Quit Listening it uses the AsyncCancel and then if say Alexis then the program responds with no errors. However if i say Quit Listening and wait longer than 10 seconds it will throw the Exception. I have tried everything i know to do. Any Ideas? I am using Visual Studio 2013 Community and its in Winforms and .NET 4.5 Framework


Can Control.Invoke() be interrupted?

When calling Control.Invoke(), it blocks the calling thread until the message gets processed. I am wondering if I can break out of this block from another thread.


Note: I know that I can use Control.BeginInvoke(), but I am not asking about that.


How to query standard file's properties? Google Drive SDK

My goal is to check all files which are shared BY me (whetever type or permissions).


So I need to find files which I'm the owner and has Shared property set to true, so I wrote the following code:



var listRequest = driveService.Files.List();
listRequest.Q = "'me' in owners and shared = 'true'";
FileList fileList = listRequest.Execute();
foreach (var file in fileList.Items)
SharedByMe.Add(file);


but the part with "shared = 'true'" doesn't working. I found that custom properties can be put in query, but what about standard ones? Because downloading all files and then checking it, is obviously not an option.


Could not install package ServiceStack.Interfaces

I'm trying to install ServiceStack nuget package- but no luck.


Environment: - Visual Studio 2012 - .Net 4.5 - Project type- Empty webSite


Command: Install-Package ServiceStack It starting package installation process but at the end of the end everything roll back and show error message:


Install-Package : Could not install package 'ServiceStack.Interfaces 4.0.38'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.3', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author. At line:1 char:16 + Install-Package <<<< ServiceStack + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand


I've tried old version of ServiceStack- but result always the same. Whould you please clarify- how to fix described issue?


Sprache for building a XAML pull parser

I’ve created a pull parser as part of my OmniXaml project. It reads an XML file and transforms it into an enumerable of XAML Nodes. Now, my goal is to do it a more elegant parser using Sprache. The thing is that I don’t even know how to start. XAML parsing heavily relies on context, so if you want yield one Xaml Node, you might have to look-ahead and process the following nodes. I currently use an XmlReader to read the XAML.


This is an example of an input/output for you to figure out what I want to do: Input (XAML):



<DummyClass xmlns="root">
<DummyClass.Child>
<ChildClass></ChildClass>
</DummyClass.Child>
</DummyClass>


Output (list of XAML Nodes):



  • Namespace Declaration of "root" with prefix: ""

  • Start of Object of type DummyClass

  • None

  • Start of Member “Child” from type “DummyClass”

  • Start of Object of type ChildClass

  • None

  • End of Object

  • End of Member

  • End of Object


Another example.


Input:



<DummyClass xmlns="root">
<DummyClass.Items>
<Item/>
<Item/>
<Item/>
</DummyClass.Items>
</DummyClass>


Output:



  • Namespace Declaration of "root" with prefix: ""

  • Start of Object of type DummyClass

  • None

  • Start of Member “Items” from type “DummyClass”

  • [Get Object] Directive

  • [Start of Items] Directive

  • Start of Object of type “Item”

  • None

  • End of Object

  • Start of Object of type “Item”

  • None

  • End of Object

  • Start of Object of type “Item”

  • None

  • End of Object

  • End of Member

  • End of Object

  • End of Member

  • End of Object


The question: How to start with this?


Could you provide me with some samples/guidelines? Thanks!


How do i get the ComboBox items text of each item?

In the constructor i did:



ComboboxItem item1 = new ComboboxItem();
item1.Text = "Processor";
item1.Value = "Win32_Processor";
ComboboxItem item2 = new ComboboxItem();
item2.Text = "DiskDrive";
item2.Value = "Win32_DiskDrive";
cmbxOption.Items.Add(item1);
cmbxOption.Items.Add(item2);

ComboboxItem[] items = new ComboboxItem[cmbxOption.Items.Count];
for (int i = 0; i < items.Length; i++)
{
items[i] = new ComboboxItem();
items[i].Text = cmbxOption.GetItemText(i);
}


But instead doing a new instance for each item and add the item to the cmbxOption i wantto make a for loop that will add all the items from the cmbOption to the ComboboxItem[]


In the form1 designer in the ComboBox in the property items i already have the items in the Collection:



Win32_1394Controller
Win32_1394ControllerDevice
Win32_BaseBoard
Win32_Battery
Win32_BIOS
Win32_Bus
Win32_CDROMDrive
Win32_CIMLogicalDeviceCIMDataFile
Win32_DeviceBus
Win32_DeviceMemoryAddress
Win32_DeviceSettings
Win32_DisplayConfiguration
Win32_DisplayControllerConfiguration
Win32_DMAChannel
Win32_DriverVXD
Win32_FloppyController
Win32_FloppyDrive
Win32_HeatPipe
Win32_IDEController
Win32_IDEControllerDevice
Win32_InfraredDevice
Win32_IRQResource
Win32_Keyboard
Win32_MotherboardDevice
Win32_OnBoardDevice
Win32_PCMCIAController
Win32_PNPAllocatedResource
Win32_PnPDevice
Win32_PnPEntity
Win32_PointingDevice
Win32_PortableBattery
Win32_PortConnector
Win32_PortResource
Win32_POTSModem
Win32_POTSModemToSerialPort
Win32_PowerManagementEvent
Win32_Printer
Win32_PrinterConfiguration
Win32_PrinterController
Win32_PrinterDriverDll
Win32_PrinterSetting
Win32_PrinterShare
Win32_PrintJob
Win32_Processor
Win32_SCSIController
Win32_SCSIControllerDevice
Win32_SerialPort
Win32_SerialPortConfiguration
Win32_SerialPortSetting
Win32_SMBIOSMemory
Win32_SoundDevice
Win32_TemperatureProbe
Win32_USBController
Win32_USBControllerDevice
Win32_VideoConfiguration
Win32_VideoController
Win32_VideoSettings
Win32_VoltageProbe


I want to take each item and create for it ComboboxItem Text and Value. Just not to do it manual.


while reader.read() give me the same result more than one time

i want to read this sql result but every time al have much result more than the sql statment retreve



Dim con As New OdbcConnection
con.ConnectionString = "Dsn=online_ordering_system;server=localhost;uid=root;database=online_ordering_system;port=3306"
con.Open()
Dim sql As String
sql = "SELECT ProductImg FROM products WHERE CategoryId=" & id

Dim dbCommand As New OdbcCommand(sql, con)
Dim dbReader As OdbcDataReader = dbCommand.ExecuteReader

If dbReader.HasRows Then
Do While dbReader.Read()

Console.WriteLine("productPhoto={0}", dbReader(0).ToString)

Loop
End If

dbReader.Close()

The type initializer for 'weka.core.WekaPackageManager' threw an exception - weka c#

I am using weka api through c#. I have converted weka jar file to c# dll by using ikvm. Then I have added the converted dll (wekacsharp.dll) in my reference.


I have also added ikvm.gnu.classpath.dll, IKVM.OpenJDK.Core.dll, IKVM.OpenJDK.Util.dll, IKVM.OpenJDK.Text.dll, IKVM.OpenJDK.Core in my reference.


I am trying to use j48 algorithm but i am getting the error. Screen shot of code error is attached. Kindly check it and suggest me something to fix it.


Code:



public static void classifyTest()
{
try
{
weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("iris.arff"));
insts.setClassIndex(insts.numAttributes() - 1);

weka.classifiers.Classifier cl = new weka.classifiers.trees.J48();
//Console.WriteLine("Performing " + percentSplit + "% split evaluation.");

//randomize the order of the instances in the dataset.
// weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize();
// myRandom.setInputFormat(insts);
// insts = weka.filters.Filter.useFilter(insts, myRandom);

int trainSize = insts.numInstances() * percentSplit / 100;
int testSize = insts.numInstances() - trainSize;
weka.core.Instances train = new weka.core.Instances(insts, 0, trainSize);

cl.buildClassifier(train);
int numCorrect = 0;
for (int i = trainSize; i < insts.numInstances(); i++)
{
weka.core.Instance currentInst = insts.instance(i);
double predictedClass = cl.classifyInstance(currentInst);
if (predictedClass == insts.instance(i).classValue())
numCorrect++;
}
//java.io.Console.WriteLine(numCorrect + " out of " + testSize + " correct (" +(double)((double)numCorrect / (double)testSize * 100.0) + "%)");
}
catch (java.lang.Exception ex)
{
ex.printStackTrace();
}
}


enter image description here


Calculating frame index based on new frame rate for video generation

My .NET application as a sequential list of images representing each frame of a video recorded at 30 frames per second.



00000001.png
00000002.png
00000003.png
...
99999999.png


Now I want to reorder this list so it can generate a video based on the following parameters:



Start Frame Index: 100
Direction: Forward
Output Speed: 100 FPS
Duration: 10 seconds


So far I have something like this:



var originalFrameRate = 30D;
var originalFrameTime = 1D / originalFrameRate;
var originalStartFrameIndex = 100; // 00000100.png.
// Assume [originalFrames] will be filled with image file names from above.
var originalFrames = new List<string>
(new string [] { "0000003.png", "0000002.png", ..., "99999999.png", });

var targetFrameRate 100; // FPS.
var targetDuration = TimeSpan.FromSeconds(10);
var targetFrameCount = speed * targetDuration.Seconds;
var targetFrames = new List<string>();

for (int i = 0; i < targetFrameCount; i++)
{
// How to map the original list from 30 FPS to 100 FPS?
targetFrames.Add(originalFrames [originalStartFrameIndex + ???]);
}


In the above example, the output would be targetFrames being filled with the appropriate file name based on the variables names targetXXX.


Any suggestions on how to map this would be appreciated.


EDIT: I forgot to mention that the output video will always be generated at the original frame rate. The length of the target video will of course change. If the original FPS is lower than the target, we will repeat frames. Otherwise we will be skipping them.


The type or namespace name 'DataSource' could not be found- weka c#

down vote favorite


I am using weka api through c#. I have converted weka jar file to c# dll by using ikvm. Then I have added the converted dll (wekacsharp.dll) in my reference.


I have also added ikvm.gnu.classpath.dll, IKVM.OpenJDK.Core.dll, IKVM.OpenJDK.Util.dll, IKVM.OpenJDK.Text.dll, IKVM.OpenJDK.Core in my reference.


I am trying to use j48 algorithm but i am getting the error. Screen shot of code error is attached. Kindly check it and suggest me something to fix it. Thanks!



J48 J48_tree = new J48(); //Creating J48 tree instance
DataSource data_source = new DataSource("iris.arff");
Instances data = data_source.getDataSet();
if (data.classIndex() == -1)
data.setClassIndex(data.numAttributes() - 1);

J48_tree.buildClassifier(data); // Builds the classifier

javax.swing.JFrame j_frame = new javax.swing.JFrame("J48 Tree");

//final javax.swing.JFrame j_frame = new javax.swing.JFrame("J48 Tree");
j_frame.setSize(1200,700);
j_frame.getContentPane().setLayout(new BorderLayout());
TreeVisualizer tree_visualizer = new TreeVisualizer(null, J48_tree.graph(), new PlaceNode2());
j_frame.getContentPane().add(tree_visualizer, BorderLayout.CENTER);

j_frame.addWindowListener(new java.awt.event.WindowAdapter() {public void windowClosing(java.awt.event.WindowEvent e) {j_frame.dispose(); }});

j_frame.setVisible(true);
tree_visualizer.fitToScreen();


enter image description here enter image description here


Sometimes Asp.Net Button Fires Event, Sometimes Not?

I'm trying to make a form-check but submit button (asp:Button) sometimes fires target method and sometimes not. I recorded my debugging operation and uploaded it to YouTube, please watch it first to understand what's going on: YouTube Link >>


I'm really confused about it. Is it just about concurrency or what? What to do? Suggestions? Thanks!


Button Code:



<asp:Button ID="RegisterButton" OnClick="Register" Text="Register" CssClass="button" runat="server" />

How could I move, rotate the heading and stop a point using C#

I am a Searcher in the Postgraduate level at faculty of Information Computing, and my graduation project involves a simulation for a movement of multiple trains, i am trying to stop a point on a specified (x,y), then i want to rotate its heading and change the (angle) of its heading. i have watched all of this videos on your youtube channel about : "Basic C# Game Programming Moving Object on the form " here : Illustrating Video which illustrates how to control the movement of the point using the KeyDown Event in the .NET, but i want to enter different locations at different times ( it will be stored in a variable and entered by a textbox or whatever ) , so if you please, guide and tell me how to rotate the heading of the point when arrived to a specified (x,y) and also how to stop it on its station (another (x,y)) in the railway network .


and if that is related to "grid networking" ??


i have found that system.Drawing has a function, which can be overloaded such as :


e.Graphics.RotateTransform(30.0F); , but i found that it is not only rotate the transform, but also changes its location, you can check it by yourself.


also i tried this method :



enter code here
int x_ex = 60, y_ex = 60;
private void increase_distance(PaintEventArgs e)
{
// draw a rectangl
e.Graphics.FillRectangle(Brushes.Blue, x_ex, y_ex, 20, 20);
// increase or decrease it's movement
x_ex = x_ex + (int)2.5;
y_ex = y_ex + (int)2.5;
// try to stop and rotate it
if (x_ex == 90)
{

//x_ex = (int)e.Graphics.Transform.RotateAt(30.0F, search on google
// (RotateTransform method) not only rotate the object but also change the location and its coordinates
e.Graphics.RotateTransform(30.0F);
// you can notice that its color will be changed for a fraction of moment when (x_ex=90)
e.Graphics.FillRectangle(Brushes.Green, 90, 90, 20, 20);



//x_ex = 0;
//y_ex = 0;


help me if you please, your help & response already will be appreciated.


Thank you.


How can I create the program that encrypts file with 2DES (doubleDES)?

I know doubleDES is not used sine of Meet-in-the-middle Attack but i need to create a program that does that kind of encryption. I tried this but i think im stuck and just cannot figure out what am i missing..


DESCryptoServiceProvider DES = new DESCryptoServiceProvider();



DES.Mode = CipherMode.ECB;
DES.Padding = PaddingMode.Zeros;
// *****ENKRIPTIMI*****
DES.Key = utf8.GetBytes(textBox1.Text.Substring(0, 8));
StreamReader sr = new StreamReader(textBox2.Text);
string permbajtja = sr.ReadToEnd();
sr.Close();
FileStream fs1 = new FileStream(textBox2.Text, FileMode.Create, FileAccess.Write);
CryptoStream cs = new CryptoStream(fs1, DES.CreateEncryptor(), CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cs);
sw.Write(permbajtja); sw.Flush();
sw.Close();
StreamReader stream = new StreamReader(textBox2.Text);
string msg = stream.ReadToEnd();
stream.Close();
MessageBox.Show(msg);



//*****DEKRIPTIMI*****

DES.Key = utf8.GetBytes(textBox1.Text.Substring(8, 8));
FileStream fs2 = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read);
CryptoStream cs1 = new CryptoStream(fs2, DES.CreateDecryptor(), CryptoStreamMode.Read);
StreamReader sr1 = new StreamReader(cs1);
string permbajtja1 = sr1.ReadToEnd();
// MessageBox.Show(permbajtja1);
sr1.Close();
fs2.Dispose();
fs2.Close();


StreamWriter sw1 = new StreamWriter(textBox2.Text);
sw1.Write(permbajtja1);
sw1.Flush();
sw1.Close();


**** THE PART ABOVE IS JUST FOR ENCRYPTING *****


The decryption part


DESCryptoServiceProvider DES = new DESCryptoServiceProvider();



DES.Mode = CipherMode.ECB;
DES.Padding = PaddingMode.Zeros;
// *****ENKRIPTIMI*****
DES.Key = utf8.GetBytes(textBox1.Text.Substring(8,8));
StreamReader sr = new StreamReader(textBox2.Text);
string permbajtja = sr.ReadToEnd();
sr.Close();
FileStream fs1 = new FileStream(textBox2.Text, FileMode.Create, FileAccess.Write);
CryptoStream cs = new CryptoStream(fs1, DES.CreateEncryptor(), CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cs);
sw.Write(permbajtja); sw.Flush();
sw.Close();
StreamReader lexo = new StreamReader(textBox2.Text);
MessageBox.Show(lexo.ReadToEnd());
lexo.Close();

////*****DEKRIPTIMI*****

DES.Key = utf8.GetBytes(textBox1.Text.Substring(0, 8));
FileStream fs2 = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read);
CryptoStream cs1 = new CryptoStream(fs2, DES.CreateDecryptor(), CryptoStreamMode.Read);
StreamReader sr1 = new StreamReader(cs1);
string permbajtja1 = sr1.ReadToEnd();
MessageBox.Show(permbajtja1);
sr1.Close();
fs2.Dispose();
fs2.Close();


StreamWriter sw1 = new StreamWriter(textBox2.Text);
sw1.Write(permbajtja1);
sw1.Flush();
sw1.Close();

Validate/read total count of file in folder, size of every single file and some text of file with any extension on local folder

I have n no. of files with many extension in local folder. I have to read count of total count of files from folder, again I have to check size of every single file, after verifying size.. .if we got any file size <0 byte . I have to report it as corrupted or could not open that file... so we can check that file by opening of every single files from folder...


I have tried following code to get count but with only one extension type. So how can get count of files from folder with all extension and how I can check size of file. And how I check whether that is corrupted. If I can open it then its sufficient.



public static int GetFileCount(string path, string searchPattern, SearchOption searchOption)
{
var fileCount = 0;
var fileIter = Directory.EnumerateFiles(path, searchPattern, searchOption);
foreach (var file in fileIter)
fileCount++;

return fileCount;
}


called above function as



GetFileCount(@"D:\Attachment", "*.png", SearchOption.AllDirectories);

getting OAuth token from API .Net [on hold]

I'm working on Visual Studio 2013,using c# with .Net. How can I get Oauth token from API which is already exists? I was watching some tutorials about creating the API and using it, but I don't really want it, just get token from API to my WPF application. Do you know some sensible tutorial or could you help me to solve my problem? I'm just getting started with problems like that.


I would be grateful for help, guys.


edit:

i've got username, password and adress to token. I want to use DotNetOpenAuth.OAuth2 or Microsoft.Owin.Security.OAuth. Should I add some more informations?


Get Lucene's n newest documents

Using Lucene.net, how can I get the n latest documents that were indexed? (ideally with the ability to skip some because I need pagination as well)


The only solution I have found so far is to make a query that returns everything and sorts by date; but this is not efficient as we are in the 2-3 million documents range right now.


Regex till first match C# and cut the string

Hi Regex gurus of this site, i have an issue trying to write regex which return first part of message till first match. I'm programming in C# language and using parameters (?is)


My current regex is: :(?<Tag>[0-9]{1,}[a-z]{0,}):(?<Value>.*?)(?=:75:|:75E:|:79:)


My sample string is:



:20:gtregeeg.::()(*&(*&(ERW
:70:fdaksjfdjkahfdkahkdahjkdafda+++----
- :20:aslfkjdklasjdlsafjkdsaf.\[[][^%$#%*$^#(
:75: asdfasdfsasfd812349798759*&)(*)((_
.5697.dsaasdfasfa()()(2435325&^&*&()*
:79:afdfdasfdas(*(&*(&)(__+-*-**--+
:75E:adfasf-++++***/*/-/-*/*++...
:20:dafsdfadfasd_+_+)((*&&^*
:75:sdafassfafdfadsafdadfaaf204392-395(**(&(&()*)
:::.....------------+-**--


How to match everything till first tag match :75: because if there are more tags in string text it continues to match. I need to match only till first found tag :75: and i don't care what follows up next. Tried to search this site for particular solution and what tried nothing helped i got the same answer that if tag occurs further in text it still matches. Thanks for help.


I have update my regex, when multiple positive look ahead so at the end .*$ doesn't help, it still produces whole string, but my desired output should be only first match, till first met on of tags:



:20:gtregeeg.::()(*&(*&(ERW
:70:fdaksjfdjkahfdkahkdahjkdafda+++----
- :20:aslfkjdklasjdlsafjkdsaf.\[[][^%$#%*$^#(

For loop, Performance

i have a few question regarding for loops, if you can point me to some sources or answer me here directly I would appreciate it.


The question is:



for(int i=0;i<List.Count();i++)
{
//some code
}


is this FASTER or SLOWER comparing to this:



int count = list.Count();

for(int i=0;i<count;i++)
{
//some code
}


and is it the same if I use Dictionatry.Count() or List.Count(). Does it always call the Count() function when it iterates in the for loop im kinda confused about this, do i gain any performance boosts?


Create function from CLR assembly - T-SQL and CLR types for return value do not match

This is on MS SQL Server 2014 but will also be used on 2008 R2.


I am attempting to use the YAddress UDF DLL found here http://ift.tt/1IZ9B29. I have created the assembly on my database and it appears under sys.assemblies.


I have created a stored procedure from the FillRow method, but I need the CallYAddress function.


I am trying to create a function on SQL Server using the EXTERNAL NAME YAddressSqlFunction.YAddressSqlFunction.CallYAddress.


The error returned by



CREATE FUNCTION ProcessAddress2008b(@Addr1 NVARCHAR(255),@Addr2 NVARCHAR(255),@user NVARCHAR(100))
RETURNS table (..here I list all the fields see code below for the list..)
AS EXTERNAL NAME YAddressSqlFunction.YAddressSqlFunction.CallYAddress


is


CREATE FUNCTION for "ProcessAddress2008b" failed because T-SQL and CLR types for return value do not match.


I think the issue is the 'table' return. What should I be returning for the UDF? The assembly fills rows but they aren't coming back as a TABLE. I have tried several things (such as IENUMERABLE) and they return the same error.


Here is the code from the DLL:



Public Shared Function CallYAddress(sAddressLine1 As String, sAddressLine2 As String, sUserKey As String) As YAddressSqlFunction.Address
Dim httpWebRequest As HttpWebRequest = DirectCast(WebRequest.Create(String.Format("http://ift.tt/1D2y6TC}", DirectCast(Uri.EscapeDataString(If(sAddressLine1 Is Nothing, "", sAddressLine1)), Object), DirectCast(Uri.EscapeDataString(If(sAddressLine2 Is Nothing, "", sAddressLine2)), Object), DirectCast(Uri.EscapeDataString(If(sUserKey Is Nothing, "", sUserKey)), Object))), HttpWebRequest)
httpWebRequest.Accept = "application/xml"
Return DirectCast(New XmlSerializer(GetType(YAddressSqlFunction.Address)).Deserialize(httpWebRequest.GetResponse().GetResponseStream()), YAddressSqlFunction.Address)
End Function

<SqlFunction(FillRowMethodName:="FillRow")> _
Public Shared Function InitMethod(AddressLine1 As String, AddressLine2 As String, Optional UserKey As String = Nothing) As IEnumerable
Return DirectCast(New YAddressSqlFunction.YAddressResults(AddressLine1, AddressLine2, UserKey), IEnumerable)
End Function

Public Shared Sub FillRow(obj As Object, ByRef ErrorCode As Integer, ByRef ErrorMessage As String, ByRef AddressLine1 As String, ByRef AddressLine2 As String, _
ByRef Number As String, _
ByRef PreDir As String, ByRef Street As String, ByRef Suffix As String, ByRef PostDir As String, ByRef Sec As String, ByRef SecNumber As String, _
ByRef City As String, ByRef State As String, ByRef Zip As String, ByRef Zip4 As String, ByRef County As String, ByRef CountyFP As String, _
ByRef CensusBlock As String, ByRef CensusTract As String, ByRef Latitude As Double, ByRef Longitude As Double, ByRef GeoPrecision As Integer)

Dim address As YAddressSqlFunction.Address = DirectCast(obj, YAddressSqlFunction.Address)

ErrorCode = address.ErrorCode
ErrorMessage = address.ErrorMessage
AddressLine1 = address.AddressLine1
AddressLine2 = address.AddressLine2
Number = address.Number
PreDir = address.PreDir
Street = address.Street
Suffix = address.Suffix
PostDir = address.PostDir
Sec = address.Sec
SecNumber = address.SecNumber
City = address.City
State = address.State
Zip = address.Zip
Zip4 = address.Zip4
County = address.County
CountyFP = address.CountyFP
CensusBlock = address.CensusBlock
CensusTract = address.CensusTract
Latitude = address.Latitude
Longitude = address.Longitude
GeoPrecision = address.GeoPrecision
End Sub

OData v4 ExtensionlessUrlHandler 500 error for 404s

Has anyone else noticed that while adding the "ExtensionlessUrlHandler-Integrated-4.0" handler enables successful resolution of valid end points with periods, it causes ANY INVALID end points (with or without a period in the URL) that should result in a 404 return a 500?


I almost think it's better to not include this handler and use a trailing slash on all urls. Any ideas?


Handler for ref:



<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>