Ajax.Pro.dll in .NET 4.5 - c#

Now, I upgrade my web application from .NET4.0 to 4.5.2.
In my app, I use Ajax.Pro.dll.
In aspx.file, call ajaxMethod like follow by javascript.
function callAjax() {
ajaxClass.ajaxMethod();
}
In cs.file there are ajaxMethod like follow.
class AjaxClass
{
[AjaxPro.AjaxMethod]
public void AjaxMethod()
{
this.textBox.text = "AjaxCalled!!";
}
}
In .NET4.0, My app ran completely. But in .NET4.5, ajaxClass is null.
Is Ajax.Pro.dll used in .NET4.5?
Please answer my problem.

Related

How can I acces microphone input in .Net MAUI?

I am developing .net maui app that measures sound volume and sends it with bluetooth to pc that logs data and makes graph as a hobby project. My problem is accesing microphone input. There seems to be no multiplatform way to do this in maui. So i tried to do it using platform specific android api, but when I tried so, it seemed like class that I needed was not fully implemented in maui Android namespace.
The part of my code I have trouble with is this:
using Android.Media;
using Java.Util;
public static class MicIn
{
static MediaRecorder mRecorder;
// Other functions
public static void startRecorder()
{
if (mRecorder == null)
{
mRecorder = new MediaRecorder();
mRecorder.SetAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.SetOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.SetAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.SetOutputFile("/dev/null");
try
{
mRecorder.Prepare();
}
catch (Java.IO.IOException ioe)
{
Debug.WriteLine("IO exception");
}
catch (Java.Lang.SecurityException e)
{
Debug.WriteLine("Security exception");
}
try
{
mRecorder.Start();
}
catch (Java.Lang.SecurityException e)
{
Debug.WriteLine("Security exception");
}
}
}
}
Visual studio gives me errors on MediaRecorder.AudioSource.MIC, MediaRecorder.OutputFormat.THREE_GPP and MediaRecorder.AudioEncoder.AMR_NB
It says that these classes do not have definition for MIC, THREE_GPP and AMR_NB constants, even if they are in official android api documentation.
Do you have any ideas what might be error or other ways of taking microphone input in .net maui? Thank you for help.
according to the docs
AudioSource Mic
OutputFormat ThreeGpp
AudioEncoder AmrNb

System.MissingMethodException: 'Method not found for XmlRpcProxyGen.Create

I'm trying to communicate with a python server using XML-RCP but when I try to compile the following code, the exception "System.MissingMethodException: 'Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.'" displays, I've found no documentation about this issue
using CookComputing.XmlRpc;
using System;
[XmlRpcUrl("http://192.168.5.211:8000")]
public interface FlRPC : IXmlRpcProxy
{
[XmlRpcMethod("add")]
int add(int x, int y);
}
class Program
{
static void Main(string[] args)
{
FlRPC proxy = XmlRpcProxyGen.Create<FlRPC>();
Console.WriteLine(proxy.add(2, 3));
}
}
I just want to skip this issue to continue to work on my project!
If the application you are trying to build is a .NET Core Application the xmlrpcnet package might be exclusively for the .NET Framework.
Try to replace it with Horizon's .NET Core port, Horizon.XmlRpc.Core and see if it helps.

How to use Roslyn in VS?

What do I need to to for this to work in C# Visual Studio?
using Roslyn.Scripting;
using Roslyn.Scripting.CSharp;
namespace RoslynScriptingDemo
{    
 class Program
{      
   static void Main(string[] args)
{
            var engine = new ScriptEngine();            
 var session = Session.Create();
engine.Execute(#"var a = 42;", session);
            engine.Execute(#"System.Console.WriteLine(a);", session);
}
}
}
That code looks like it was written to use a much older version of Roslyn, and I don't think that NuGet packages to support it are available anymore. Take a look at https://github.com/dotnet/roslyn/wiki/Scripting-API-Samples for information on using Microsoft.CodeAnalysis.CSharp.Scripting, which is current.
Here's how you might do something similar in VS2017:
using Microsoft.CodeAnalysis.CSharp.Scripting;
static async Task Main(string[] args)
{
var state = await CSharpScript.RunAsync("var a = 42;");
Console.WriteLine(state.GetVariable("a").Value);
}

XSockets - custom controller is not registering

I've been trying to evaluate XSockets but it appears I've hit my first stumbling block pretty early. I can connect to Generic controller just fine but custom controllers do not seem to work at all - I get a custom message: "The handler name was not found in loaded plugins". A Google search shows one other person having this problem in SE, but their solution did not work for me.
I've created a console project and installed the latest XSockets 3.03 from NuGet. My code is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XSockets.Core.Common.Socket;
using XSockets.Core.XSocket;
using XSockets.Core.XSocket.Helpers;
using XSockets.Core.Common.Socket.Event.Interface;
namespace XSockets2
{
class Program
{
static void Main(string[] args)
{
using (var server = XSockets.Plugin.Framework.Composable.GetExport<IXSocketServerContainer>())
{
Console.WriteLine("running!");
server.StartServers();
Console.ReadLine();
server.StopServers();
}
}
}
public class TestCont: XSocketController
{
public override void OnMessage(ITextArgs textArgs)
{
this.SendToAll(textArgs);
}
}
}
And my Javascript
function connect2() {
var host = "ws://localhost:4502/testcont";
var conn;
conn = new XSockets.WebSocket(host);
conn.on(XSockets.Events.open, function (clientInfo) {
message(clientInfo.ClientGuid); //appends message to textarea
console.log('Open', clientInfo);
});
conn.on('OnMessage', function (d) {
message(d);
console.log('Message', d);
});
conn.on(XSockets.Events.onError, function (err) {
message(err.CustomMessage);
console.log('Error', err);
});
conn.on(XSockets.Events.close, function () {
message('Closed');
console.log('Closed');
});
First of all the latest version is 3.0.2 (not 3.0.3) but that is not important :)
There is a well known and documented bug in the plugin framework for the latest version. The bug only affect you if you run a console application (or any other *.exe) project since xsockets by default only looks in *.dll and not *.exe.
The issue and work around is described here
But your code will not work anyway since you have an error (from what I can see).
Your controller is named "TestCont" but you connect to "testcont". The connectionstring is case sensitive.
EDIT: I also think you are missunderstanding the method OnMessage since you have added a subscription to that exact name.

Nancy Self Host doesn't call Module?

I am working on adding Nancy Framework to my C# console application (followed the very short tutorial here and it loads a blank page when I go to http://localhost:1234 so I know it is starting, but it doesn't show my text properly. I have gone over my code various times, but don't see any issues.
I have added both Nancy and Nancy.Hosting.Self to my project.
static void Main(string[] args)
{
var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
nancyHost.Start();
Console.ReadLine();
nancyHost.Stop();
}
namespace DaemonApp
{
class MainModule : Nancy.NancyModule
{
public MainModule()
{
Get["/"] = parameters =>
{
return "Hello world!";
};
}
}
}
I added some print lines, and it never calls the module when I visit the page. Does anyone have any clue what the issue is?
I didn't make the Module class public, that fixed it instantly =/

Categories

Resources