I built a WCF component resident in IIS. I have tested it and it appears to work correctly, however I'm trying to access it via the .NET Standard Class without success.
Could someone exemplify how we are expected to set C# commands to access the WCF methods?
The Visual Studio 2017 'Add Connected Service' dialogue with C# was used in a .NET Standard 2.0 Class.
Further detail
In reference.cs file there is
public interface IAvisaWCF
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAvisaWCF/DoAccess", ReplyAction="http://tempuri.org/IAvisaWCF/DoAccessResponse")]
System.Threading.Tasks.Task DoAccessAsync(string INT_IdFisico, int INT_Id, int DI_ID, string DI_IDFisico, char Numero_Leitor, string Mobile_EMEI);
public partial class AvisaWCFClient : System.ServiceModel.ClientBase<AvisaWCFRef.IAvisaWCF>, AvisaWCFRef.IAvisaWCF
{
public System.Threading.Tasks.Task DoAccessAsync(string INT_IdFisico, int INT_Id, int DI_ID, string DI_IDFisico, char Numero_Leitor, string Mobile_EMEI)
{
return base.Channel.DoAccessAsync(INT_IdFisico, INT_Id, DI_ID, DI_IDFisico, Numero_Leitor, Mobile_EMEI);
}
In the Net Standard Class (stantiated in a Android Class) I had instantiated the component and Called de Async Method, like this;
AvisaWCFRef.AvisaWCFClient oComp = new AvisaWCFRef.AvisaWCFClient();
oComp.DoAccessAsync(Int_IdFisico, Int_Id, DI_ID, DI_IdFisico, Numero_Leitor, Mobile_EMEI);
The system then gave me the following error:
Unhandled Exception:
System.ServiceModel.FaultException`1 [[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version = 2.0.5.0,
Culture = neutral, PublicKeyToken = 31bf3856ad364e35]]:
An error occurred during deserialization of the request message body for the DoAccess operation.
The OperationFormatter encountered an invalid message body.
It was hoped to find 'Element' node with name 'DoAccess' and namespace 'http://tempuri.org/'.
Found element node with name 'DoAccessAsync' and namespace 'http://tempuri.org/' occurred
Could someone exemplify how I'm supposed to set C# commands to access the WCF methods?
Related
In my app I tried reducing the amount of places I needed to update a string name, so I added a string in the Resources/values/Strings.xml file, but when I tried to test my build I got a weird error that I coudnt find a solution on, and have no idea why its doing that.
Someone know anything about this?
heres the xml code:
<resources>
<string name="service_name">ITMNotificationService</string>
</resources>
Using it in a Service attribute:
[Service (Label = "#string/service_name"
, Name = "#string/service_name"
, Icon = "#drawable/ITMIcon"
)]
And the error in the console;
The Name parameter for the ServiceAttribute is defining the Java class name that will be used in the ACW that is generated at compile time.
Thus the literal string of #string/service_name can not be used for a Java class name as that is invalid. Typically this would be the fully-qualified class name that includes your package id, ie.
Name = "com.sushihangover.coolapp.mywickedservice"
You could define this via a C# const string, but not an Android resource-based string value.
Note: You do not need to define the Name and Xamarin will auto-generated one via an MD5 hash routine. You then use typeof instead of the Java class name when calling the StartService method.
I am getting a System.TypeInitializationException in C# when i try to call the following:
List<BuyShopItem> buyShopItemList = new List<BuyShopItem>(0);
BuyShopItem is in an external assembly and contains the following:
namespace GameProtocol
{
public struct BuyShopItem
{
public int ShopItemID;
public int Amount;
public int GoldPrice;
public int SilverPrice;
public int CharacterPointPrice;
public int ResearchPointPrice;
}
}
It's probably because of the external assembly, right?
Unfortunately, i cannot change it as i need to pass the BuyShopItem back again to another external Assembly.
Some information about the assembly: It's from a Unity game, .NET 3.5 (according to DotPeek: msil, .Net Framework v3.5)
I'm having the issue in SharpDevelop as well as Visual Studio 2017, so it probably not IDE-related.
Result of peverify:
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
[MD]: Error: Field has a duplicate, token=0x040059d7. [Token:0x040059CF]
[MD]: Error: Field has a duplicate, token=0x040059cf. [Token:0x040059D7]
[MD]: Error: Field has a duplicate, token=0x0400a48b. [Token:0x0400A478]
[MD]: Error: Field has a duplicate, token=0x0400a478. [Token:0x0400A48B]
4 Fehler wird/werden überprüft Assembly-CSharp.dll
If you have any Hints of what it could be, please tell me. I will try it out as soon as i can.
Here is a screenshot of the Exception in Visual Studio 2017:
https://i.imgur.com/WHCbWTM.png
Update: I just tried the following: Console.WriteLine(typeof(BuyShopItem));, same error occured. Why isn't it possible to get the type?
It is OK to create a zero-length list of structs.
It is also OK to create a list of some type that is defined in a different assembly - but check to make sure that the necessary DLL can be located at runtime.
Instances of structs are generally fairly safe to construct - but check to see if there is a custom constructor that is throwing an exception.
Also carefully check to see if the BuyShowItem struct specifies any static fields that call into other code, which in turn may be failing. This is often the root cause of TypeInitializationException.
See: https://msdn.microsoft.com/en-us/library/system.typeinitializationexception(v=vs.110).aspx
I have a mature C# application that has always been run on Windows that is being ported to Linux (on Mono), and I am running into an error that I cannot resolve regarding PluralizationServices in System.Data.Entity.Design.
The line of code causing the problems is as follows:
PluralizationService pluralizationService = PluralizationService.CreateService(System.Globalization.CultureInfo.InvariantCulture);
Although this has never caused any problems on the Windows application running under Microsoft.NET, when the program is running under Mono I get the following error:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
File name: 'System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I found here someone else who seemed to be having a similar problem had simply copied the .NET version of the .dll over to their Mono project, and it resolved the issue for them. I tried the same, however I then encountered the following error:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for MudSharp.Framework.LanguageHelpers ---> System.InvalidProgramException: Invalid IL code in System.Data.Entity.Design.PluralizationServices.PluralizationService:CreateService (System.Globalization.CultureInfo): method body is empty.
I'm using Mono 3.10 on Ubuntu. I can't find any suggestion that Mono doesn't support these functions, and I'm simply unsure how to proceed with debugging this issue.
Any help would be appreciated.
Looks like latter versions of Mono do support the PluralizationService - see function support status.
However, the PluralizationService currently only supports English.
Have you tried this:
PluralizationService pluralizationService = PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us"));`
FYI, looks easy enough to extend to other languages using the EntityModelSchemaGenerator class.
Plurally is a Mono-compatible replacement to the Entity Framework pluralization services.
use Plurally test library source code jsonclassgenerator
IDE: Xamarin Studio 6.1.3
framework: Mono / .NET 4.5
add NuGet package: Newtonsoft.Json, Plurally
JsonClassGenerator.cs line 10,39
use Plurally.Pluralizer
using Plurally;
private Pluralizer pluralizationService = new Pluralizer(new CultureInfo("en-us"));
JsonType.csline 8
using Plurally;
Xamasoft.JsonClassGenerator.JsonClassGenerator GenerateClasses Result
{
"UserAccount": "",
"UserPassword": "",
"ExtraInfo": ""
}
// Generated by Xamasoft JSON Class Generator
// http://www.xamasoft.com/json-class-generator
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace CommonModels
{
public class loginArgs
{
public string UserAccount { get; set; }
public string UserPassword { get; set; }
public string ExtraInfo { get; set; }
}
}
I've build a classlibrary using c# and the .net framework 3.5. In my class library there is a class called Utilities with two methods.
public string Method1(int length)
{
}
public string Method2(int length, string aStringParameter)
{
}
Now I went and build a simple asp page calling my methods. Method1 work like a charm. Method2 causes a "Type Mismatch" error. What am I missing here?
Try to put
MarshalAs(UnmanagedType.BStr)
for string type that you are passing to method2.
Here is a detailed explanation.
F# declared namespace is not available in the c# project or visible through the object browser.
I have built a normal F# library project, but even after i build the project and reference it to my C# project, I am unable to access the desired namespace.
I am also unable to see it in the object browser, i get an error telling me that it has not been built. I am running on the september release can someone point out my error ?
F# Version 1.9.6.0
(6) Edit : Referencing the dll directly has fixed my problem, referencing the project allows me to compile but the intellisence does not work. When the dll is directly referenced the intellisence works perfectly.
This is the code found in the .fs file
#light
namespace Soilsiu.Core
module public Process =
open System.Xml.Linq
let private xname (tag:string) = XName.Get(tag)
let private tagUrl (tag:XElement) = let attribute = tag.Attribute(xname "href")
attribute.Value
let Bookmarks(xmlFile:string) =
let xml = XDocument.Load(xmlFile)
xml.Elements <| xname "A" |> Seq.map(tagUrl)
let PrintBookmarks (xmlFile:string) =
let list = Bookmarks(xmlFile)
list |> Seq.iter(fun u -> printfn "%s" u)
(5) Edit : Could ReSharper 4.0 be the problem?
(4) Edit : When i say the Object browser is unable to read the resulting assembly, i mean that when I try to open the assembly in the object browser i get an error telling me the project has not yet been built. yet again i can read the assembly using reflector.
(3) Edit : Reflector can Disassemble the dll but the Object Browser is unable to read it.
(2) Edit : I have Upgraded my F# version to 1.9.6.2 and still the same consequence
(1) Edit : I was able to Disassemble the dll to C# I get : (Everything seems to be fine here)
namespace Soilsiu.Core
{
[CompilationMapping(7)]
public static class Crawler
[CompilationMapping(7)]
public static class Process
}
[CompilationMapping(7)]
public static class Process
{
// Methods
static Process();
public static IEnumerable<string> Bookmarks(string xmlFile);
public static void PrintBookmarks(string xmlFile);
internal static string tagUrl(XElement tag);
internal static XName xname(string tag);
// Nested Types
[Serializable]
internal class clo#13 : FastFunc<XElement, string>
{
// Methods
public clo#13();
public override string Invoke(XElement tag#9);
}
[Serializable]
internal class clo#17 : FastFunc<string, Unit>
{
// Methods
public clo#17();
public override Unit Invoke(string u);
}
}
What if you reference the produced DLL directly (i.e., not via a project reference, but via a file reference)?
Maybe IntelliSense is just messed up? What compiler error do you get when you try to use it in C#? When you say "the object browser is unable to read it" what does that mean?
For what it's worth, I added this to a F# library project, referenced it (project) from a C# console app, and was able to use it. IntelliSense did not work at first though. (Had to rebuild.)
If you can make a solid repro, I'd suggest emailing it to F# bugs alias (fsbugs).
I tried the same thing. It looks as if Visual Studio and Resharper 4.0 doesn't understand F# for some reason. If you ignore the sea of red text and the lack of intellisense, it will compile fine.
Try
Make sure that C# project is targeted FULL .NET (NOT Client Profile).
Add references to assemblies into C# project which are used by F# project.