SignalR, Owin do not work after VS2015 move and package updates - signalr

I recently upgraded to VS2015 (did not remove VS2013 or 2010). NuGet did not instal properly. While the project ran it loaded with streaming messages re package updating. I just removed and reinstalled NuGet and updated all packages.
Now I have 2 problems that could be related.
1) 134 errors. Everything to do with SignalR and Owin is failing with messages like:
'type or namespace 'Hub' could not be found'.
Here is the key code. Other Usings were greyed out as unnecessary, and are removed.
using System;
namespace SignalR
{
[Microsoft.SignalR.HubName("SeekerHub")]
public class SeekerHub : Hub
{
private static Decimal number;
public static void SendMessage(string message)
{
//StartTimer();
//var callingClient = Context.ConnectionId;
var hubContext = GlobalHost.ConnectionManager.GetHubContext<SeekerHub>();
if (Decimal.TryParse(message, out number))
{
if (number == 0)
{ }
hubContext.Clients.All.receiveUpdate(message);
}
else
hubContext.Clients.All.receiveNotification(message);
}
}
}
2) 6 warnings that relate to updating. All relate to the same SignalR/Owin area but the message suggests that it is looking in the VS2013/localhost xyz/ file and not in the VS2015 file. Is there a way I can change the pointer when the package looks to update itself?
Thanks, in advance, for any help.

Related

Can't get access to the Events in Visual Studio Community Toolkit

I'm trying to migrate my old Visual Studio extension to the new 2022 Studio. Found some fancy solution named 'Community Visual Studio Toolkit', but got some issues. When I use the ProvideAutoLoad attribute for loading my extension when a user opens some solution, I can't get access to the WindowEvents which I need to sign my event handlers. This is the error on debugging: https://snipboard.io/yUXIed.jpg
So this is the code I use, and here I have the error:
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.RegisterCommandsAsync();
VS.Events.WindowEvents.ActiveFrameChanged += WindowEvents_ActiveFrameChanged;
}
}
And the thing is my old implementation works with this code:
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.RegisterCommandsAsync();
// Getting `DTE2 dte` trough standard way...
dte.Events.WindowEvents.WindowActivated += WindowEvents_WindowActivated;
}
}
But I don't want to use old kinds of code in the new extension version, so, how to fix this issue in first example of implementation?
Well, I'm not sure about the "perfection" of this solution, but with this line of code added before access to the events - it works.
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
Seems like you have to be in main thread to access these events.

Xamarin Amazon IAP error using D8+R8 with Proguard in Release Failing but working Debug

I am using AmazonIapV2Android.dll provided by Amazon team for the Xamarin.Android project. I have implemented it last year and have been using successfully with Dx+proguard with using proguard rules as below. Those lines are also suggested by Amazon documentation. see the link
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
Recently I have changed my xamarin.android project using d8+r8 using the same proguard file. Everything, google iap implementation also fine but Amazon IAP started throwing exception.
Jsonable.CheckForErrors
(System.Collections.Generic.Dictionary`2[TKey,TValue] jsonMap)
com.amazon.device.iap.cpt.AmazonException: java.lang.RuntimeException:
Missing type parameter.
at com.amazon.device.iap.cpt.RequestOutput.CreateFromJson
(System.String jsonMessage) [0x0002d] in
<26520843ea114e5a91256077e0412906>:0 \n at
com.amazon.device.iap.cpt.AmazonIapV2Impl+AmazonIapV2Base.GetProductData
(com.amazon.device.iap.cpt.SkusInput skusInput) [0x00013] in
I am using also linker as User and sdk assemblies, this is triggering obfuscation obviously and some methods are removed by the linker because using Sdk assemblies only or No Linking, everything works fine.
I have added the AmazonIapV2Android as linker to skip but it didnt help.
When I check the code implementation of the RequestOutput.CreateFromJson function implementation, it looks like as below.
using com.amazon.device.iap.cpt.json;
namespace com.amazon.device.iap.cpt
{
public sealed class RequestOutput : Jsonable
{
public string RequestId{get;set;}
public static RequestOutput CreateFromJson(string jsonMessage)
{
try
{
Dictionary<string, object> jsonMap = Json.Deserialize(jsonMessage) as Dictionary<string, object>;
Jsonable.CheckForErrors(jsonMap);
return CreateFromDictionary(jsonMap);
}
catch(System.ApplicationException ex)
{
throw new AmazonException("Error encountered while UnJsoning", ex);
}
}
and implementation for Jsonable in the dll looks as below
namespace com.amazon.device.iap.cpt
{
public abstract class Jsonable
{
public static Dictionary<string, object> unrollObjectIntoMap<T>(Dictionary<string, T> obj) where T:Jsonable
{
Dictionary<string, object> jsonableDict = new Dictionary<string, object>();
foreach (var entry in obj)
{
jsonableDict.Add (entry.Key, ((Jsonable)entry.Value).GetObjectDictionary());
}
return jsonableDict;
}
public static List<object> unrollObjectIntoList<T>(List<T> obj) where T:Jsonable
{
List<object> jsonableList = new List<object>();
foreach (Jsonable entry in obj)
{
jsonableList.Add(entry.GetObjectDictionary());
}
return jsonableList;
}
public abstract Dictionary<string, object> GetObjectDictionary();
public static void CheckForErrors(Dictionary<string, object> jsonMap)
{
object error;
if (jsonMap.TryGetValue("error", out error))
{
throw new AmazonException(error as string);
}
}
}
}
I have tried to use linker.xml with settings like below also but it didnt help either.
<assembly fullname="AmazonIapV2Android">
<namespace fullname="com.amazon.device.iap.cpt" />
<namespace fullname="com.amazon.device.iap.cpt.log" />
<namespace fullname="com.amazon.device.iap.cpt.json" />
</assembly>
I cannot figure out why should throw exception while i am defining keepclass for all methods and members under the namespace starting with com.amazon prefix.
Any idea what could be the reason here?
EDIT: just had several more tests and my initiale comment was slightly wrong. strange way app is working in debug with Linker set "SDK assemblies only" but in release it doesnt work even with "SDK assemblies only"
Obviously this is a known problem for using R8 and Amazon IAP. Typical amazon doesnt care and update their package. especially there is no update for Xamarin IAP since 2016.
Here are the links to problem
https://forums.developer.amazon.com/questions/205480/in-app-billing-not-working-since-android-studio-de.html
https://issuetracker.google.com/issues/134766810
Currently there are 3 workarounds,
disable r8. Bad is that no obfuscation, no optimization.
Use dx+proguard+multi dex instead of d8+r8. There is a problem here if you use androidx, androidx libraries dont work with dx+proguard, they work only with d8+r8, you need to go back to support libraries.
I am not sure but amazon website claims that it is claimed, it works with r8 but this is pobably for the android java library not for xamarin. Because as i cheked there is newer version to as jar. You can theoretically use Binding library to get a new dll and try but I read even for Android studio projects, this doesnt work. So i tried to create a binding library and it had many errors and api seems to be different than xamarin. It is a lot of effort for non-profitable app store.
here is the link to github issue on xamarin.android as well.

.NET Core Error 1053 the service did not respond to the start or control request in a timely fashion

I created a Windows Service starting from my .NET Core project following this
After this, I installed correctly it on my working machine and started it.
This is my service class:
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading.Tasks;
namespace xxx
{
public class WindowsService
{
static void Main(string[] args)
{
System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
using (var service = new Service())
{
ServiceBase.Run(service);
}
}
}
internal class Service : ServiceBase
{
public Service()
{
ServiceName = "...";
}
protected override void OnStart(string[] args)
{
try
{
base.OnStart(args);
Task.Run(() => xxxx);
}
catch (Exception ex)
{
EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
}
}
protected override void OnStop()
{
base.OnStop();
}
protected override void OnPause()
{
base.OnPause();
}
}
}
So, I copied the file and installed it also on a server. Here, when I try to start it, I get:
After this, I start a lot of googling... for example, I tried the following steps :
Go to Start > Run > and type regedit
Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
With the control folder selected, right click in the pane on the right and - select new DWORD Value
Name the new DWORD: ServicesPipeTimeout
Right-click ServicesPipeTimeout, and then click Modify
Click Decimal, type '180000', and then click OK
Restart the computer
The weird point here is that the voice ServicesPipeTimeout didn't exist and I created it. Comparing the server with my working machine, there are also other value not present in the server. They are:
ServicesPipeTimeout
OsBootstatPath
Here the screenshot of regedit from the server:
Are these relevant?
I also tried to reinstall the service, recompile my files... how can I fix this problem? The error appears immediatly, it doesn't wait any timeout!
I had this problem when I switched my project to another location.
When I moved the project, I had copied the files in bin/debug folder too. The issue was resolved after I cleared the debug folder and created a new build.
See if this works!
It's a bit old question but someone may find this useful.
So I had the following code in Program.cs:
builder.SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json")
Changed it to:
builder.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).AddJsonFile("appsettings.json")
This seemed to fix the problem for me.
The problem with this error is that it is super generic.
Hopefully MS will give us some log in the future.
if you check the windows event viewer under applications it tells you what exactly is the exception that causes this error.
in my case the problem was i published the service in net6 and tried to run it on a pc with net7 installed. apparently it requires the exact major version that was used to publish the app.

MvvmCross - Windows Phone 8 + SQLite - Could not open database file

I am using MvvmCross to create Android, WPF and Windows Phone 8/8.1 apps. I've gotten SQLite working fine in the WPF and Android apps.
With the Windows Phone app, I am running into an issue when calling Create() on the SQLite database file.
The first time this is called, the create and open work just fine, but when the create() is called a second time it always fails.
Code:
ISQLiteConnection db = factory.Create("filename.sql");
db.Close();
Error:
"Could not open database file: filename.sql (CannotOpen)"
Stack:
at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at Cirrious.MvvmCross.Plugins.Sqlite.WindowsPhone.MvxWindowsPhoneSQLiteConnectionFactory.Create(String address)
at MvvmCrossPOC.Core.Services.MetadataService.OpenDatabase()
I followed this article, and others with similar steps, and added the MvvmCross SQLite Plugin (v3.5 - Install-Package MvvmCross.HotTuna.Plugin.SQLite), but the error remained.
WP8 SQLite error: The specified module could not be found
Any thoughts on how to move forward?
Code Sample:
public MetadataService(ISQLiteConnectionFactory SQLiteConnectionFactory)
{
factory = SQLiteConnectionFactory;
}
public List<Platform> GetPlatformCollection()
{
db = factory.Create(METADATA_REPO_NAME);
try
{
return db.Table<Platform>().ToList();
}
finally
{
db.Close();
}
}
Arg! Hours to figure out this was all me writing the code incorrectly.
Remember: Services are Singletons...so, you don't have to open and close the database every time you use it!
Figured that out after finding Stuart's SQLite example: KittensDB
Not sure why I didn't see this issue on any other platforms...
Working Code Sample
public MetadataService(ISQLiteConnectionFactory factory)
{
//Get the connection
db = factory.Create(METADATA_REPO_NAME);
db.CreateTable<PlatformStorage>();
db.CreateTable<DashboardStorage>();
}
public List<Platform> GetPlatformCollection()
{
return db.Table<Platform>().ToList();
}

Get Assembly version on windows phone 7

In my c# applications I usually get the version (to show the customer) using the following code:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
This does not work in Windows Phone 7 (it hangs the emulator, and phone crashing is a no-no for MS).
So, how do I get the version of the executing on a windows phone 7 device??
[Update] as noted in the comments below, calling GetName() in a wp7 app seems to be the problem.
Try this:
private static string GetVersionNumber()
{
var asm = Assembly.GetExecutingAssembly();
var parts = asm.FullName.Split(',');
return parts[1].Split('=')[1];
}
Does parsing it out of
Assembly.GetExecutingAssembly().FullName
work for you?
example output: SomeApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
edit: don't need to go through ManifestModule
First, I think it's more apt to use the assembly's file version info for conveying the application version to the user. See http://techblog.ranjanbanerji.com/post/2008/06/26/Net-Assembly-Vs-File-Versions.aspx
Second, what about doing this:
using System;
using System.Linq;
using System.Reflection;
public static class AssemblyExtensions
{
public static Version GetFileVersion(this Assembly assembly)
{
var versionString = assembly.GetCustomAttributes(false)
.OfType<AssemblyFileVersionAttribute>()
.First()
.Version;
return Version.Parse(versionString);
}
}
public static string GetVersion()
{
return Regex.Match(Assembly.GetExecutingAssembly().FullName, #"Version=(?<version>[\d\.]*)").Groups["version"].Value;
}
is fairly clean as well.

Resources