Invalid Servicestack license [closed] - servicestack

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I get this runtime exception when trying to use my new license.
This license is invalid. Please see servicestack.net or contact team#servicestack.net for more details. The id for this license is '[MyLicenseNumber]'
Am I doing anything wrong? I have tried both ways (app.config/code) of registering the license. The application is a console app using the Servicestack.Redis nuget package.
Of course the license is a Servicestack.Redis license and of course the team#servicestack.net have been contacted without reply.

If you have followed the examples provided Subscription section of the ServiceStack.net website and it is not working then you will need to wait for your reply from team#servicestack.net, as there must be an issue with the code itself.
Things to note if you are using a console app:
You would need to include an app.config not a web.config to configure it from settings file.
To configure from code, you need to run ServiceStack.Licensing.RegisterLicense before initialising the AppHost i.e. before appHost.Init();
Web.config / App.config:
<appSettings>
<add key="servicestack:license" value="XXXX-TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gUHJvaW4gY29udmFsbGlzIHRyaXN0aXF1ZSBlcm9zIG5lYyBsYWNpbmlhLiBJbnRlZ2VyIHNlZCBqdXN0byBldSBhbnRlIHRpbmNpZHVudCBjb25zZWN0ZXR1ci4gU3VzcGVuZGlzc2UgZ3JhdmlkYSBk" />
</appSettings>
In code self hosted console application:
public static void Main()
{
ServiceStack.Licensing.RegisterLicense(#"XXXX-TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gUHJvaW4gY29udmFsbGlzIHRyaXN0aXF1ZSBlcm9zIG5lYyBsYWNpbmlhLiBJbnRlZ2VyIHNlZCBqdXN0byBldSBhbnRlIHRpbmNpZHVudCBjb25zZWN0ZXR1ci4gU3VzcGVuZGlzc2UgZ3JhdmlkYSBk");
var appHost = new AppHost();
appHost.Init();
...
}
In code ASP.NET application:
protected void Application_Start(object sender, EventArgs e)
{
ServiceStack.Licensing.RegisterLicense(#"XXXX-TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gUHJvaW4gY29udmFsbGlzIHRyaXN0aXF1ZSBlcm9zIG5lYyBsYWNpbmlhLiBJbnRlZ2VyIHNlZCBqdXN0byBldSBhbnRlIHRpbmNpZHVudCBjb25zZWN0ZXR1ci4gU3VzcGVuZGlzc2UgZ3JhdmlkYSBk");
}
The license code in the examples are fictitious, replace with your own real code
Also note that if you base64 decode the license key after the prefix of XXXX- you should see the components of the key. If your key does not have data similar to this on decoding, the value may be damaged.
{
Ref: XXXX,
Name: Your Name,
Type: Business,
Hash: ZGhmc2tqaGZkamtuamt0aDNpdGtqZmtmaGtzamZuazQzaGtmam5za2pzZGhjaWtqbjQzdWhqa3Jl,
Expiry: 2015-01-01
}

Resolved by Updating the servicestack nuget packages.
I'm not sure why that solved my issue because the new version was not a major update (4.0.5 -> 4.0.15). Perhaps it was due to a version mismatch. One of my library projects used version 4.0.12.
I got a reply from team#servicestack.net which confirmed correctness of my usage of the code and the code itself.

Related

Unable to find assembly on Azure Mobile Service

I have an Azure Mobile Service project which has a dependency to another (persistence) project which is referencing FluentNHibernate. Locally everything is running correctly in Release and Debug mode. Publishing the project seems to be successful (blue smiley). The problems starts when I make a request, where FluentNHibernate is used. I get the following error message:
Unable to find assembly 'FluentNHibernate, Version=2.0.3.0, Culture=neutral, PublicKeyToken=null'.
I already tried a lot of things:
Reinstalling packages
A new plain vanilla Mobile Service
Adding dependentAssembly in Web.config in the main project and App.config in the persistence project.
A little confusing for me is following fact: When I change the version of the FluentNHibernate package, I can see in the publish preview window that this dll will not be updated.
I am really not sure if this problem is depended to this specific package (FluentNHibernate). For example, what means: PublicKeyToken=null?
What else can I try to make the service running in the cloud?
The code below worked for my solution. It wires up a handler to the AppDomain's AssemblyResolve event, which is raised if an assembly cannot be found. In this case, I tell it to check the currently loaded assemblies and return one if there is a match, which there should be for FluentNHibernate. Try sticking this as the first line in WebApiConfig.Register
public static void Register()
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
return AppDomain.CurrentDomain.GetAssemblies()
.Where(a => a.FullName == args.Name).FirstOrDefault();
};
// the rest of WebApiConfig.Register...
}

How do I get telemetry into a Windows 10 UWP App?

The Azure documentation for App Insights doesn't appear to have fresh articles relating to Windows 10 UWP Apps specifically. This appears to be endemic throughout all services (Notification Hub, Mobile Apps, Azure AD, etc.). So far I have found only references to Windows 8/8.1 Universal apps. I'm not sure how applicable they are but some code snippets do seem to compile at least.
My problem is that I have just setup a new App Insights instance for a 'WindowsStore App'. This is intended for a Windows 10 UWP app.
In my app, I have done the following:
Ingested the nuget package for App Insights which has created an ApplicationInsights.config file.
Updated the Instrumentation Key with the one from my WindowsStore App Insights Instance in the Azure Portal.
Added Internet (Client) capability in application manifest.
Created a static TelemetryClient that I use throughout all my Views / View Models.
private static TelemetryClient telemetry = new TelemetryClient();
public static TelemetryClient Telemetry
{
get { return telemetry; }
}
Updated the WindowsAppInitializer to include several WindowsCollectors.
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
WindowsCollectors.Metadata |
WindowsCollectors.Session |
WindowsCollectors.PageView |
WindowsCollectors.UnhandledException
);
Added an event handler within App.xaml.cs for Unhandled Exception and call TelemetryClient.TrackException on the exception.
private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ViewModelDispatcher.Telemetry.TrackException(e.Exception);
}
Added TelemetryClient.TrackPageViews to OnNavigatedTo overrides in my views.
But so far, after doing all that, my App Insights dashboard in the Azure Portal is showing zip, zilch, nada. :\
This makes me think one of two things is going on. Either I am missing some critical piece of this recipe or I'm still within the refresh window for the App Insights Dashboard.
Have you tried to include your instrumentation key to the call of InitializeAsync?
I'm using the following code at the constructor of App class.
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
"YOURINST-RUME-NTAT-IONK-EY012345678",
WindowsCollectors.Metadata |
WindowsCollectors.PageView |
WindowsCollectors.Session |
WindowsCollectors.UnhandledException);
I haven't confirmed the current specs (yes...the documentation of ApplicationInsight is an labyrinth :( ), but from AI v1.0, you have not to include your instrumentation key to your applicationinsight.config. Instead of it, you can specify the key with the call of initializer.
Recently found this (i work on the AI team and it still happened to me!).
If you manually added the applicationinsights.config file, make sure it is set to "Content" and "Copy if newer" in the project settings. If it isn't, then the sdk can't find the instrumentation key at runtime, since the applicationinsights.config file didn't get deployed to the device.
Update 1/11/2016: i just learned of another issue that can cause this: comments in the xml file that look like xml tags.
If your config file has any comments of the form:
<!-- <InstrumentationKey>anything</InstrumentationKey> -->
Or
<!--
Learn more about Application Insights configuration with ApplicationInsights.config here:
http://go.microsoft.com/fwlink/?LinkID=513840
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
-->
(Like is common in examples you might have gotten online, or migrating from a previous version of the AI SDK's)
If those comments appear in your config file before your real key, then the win10 sdk startup code will find those in the comments instead of your real key.
So if you see debug output that says it is using the literal string "YourKey" instead your actual key, that's the reason. (The win10 sdk uses a regex to find your key instead of loading system.xml assemblies to parse the file)

How to use Restrict attribute in service stack

Is there any documentation on use of [Restrict] attribute with service stack?
Not finding any documentation, I started trying to figure this out. I discovered you have to enable restrictions in AppHost.cs Configure event with
var endpointHostConfig = new EndpointHostConfig
{
EnableAccessRestrictions = true,
};
Then I added attributes to my request DTO:
[Route("Hello/World", "GET")]
[Restrict(EndpointAttributes.InternalNetworkAccess)]
This does not work...looks like that removes all 'default' restrictions and replaces it with just that one restriction? Using this instead seems to work:
[Restrict(InternalOnly = true)]
When I do a GET from the local lan it works, but from remote it does not. Interesting, the 'detailed stack error' it gives from remote is:
The following restrictions were not met: '\n -[InternalNetworkAccess, Secure, HttpHead, HttpPost, HttpPut, HttpDelete,
HttpOther, OneWay, Soap11, Soap12, Xml, Jsv, ProtoBuf, Csv, Html, Yaml, MsgPack, FormatOther, AnyEndpoint]'
Note, it does not even list HttpGet as one of the possiblities - which does work. Also mentions Secure and not InSecure...neither of which I am specifically requiring.
Can we get some clarification on exactly how this is supposed to work? What if I wanted to require SSL - how would I specify that?
What if I wanted to require SSL in production, but not staging on all services for this endpoint? (Realizing this may be a completely different way to configure).
The [Restrict] attribute feature is in the latest version of ServiceStack. Currently the only documentation for this exists in the Security wiki page.
Here are some EndpointAttributes restrictions tests that test the validation of the restriction attributes, and some different service configurations you can use.
The way it works is that it's restricted to anything that's specified, so if you want to enable SSL and leave everything else as unrestricted, you would only add:
[Restrict(EndpointAttributes.Secure)]
public class SslOnly { }
It also supports specifying multiple combinations of environments that are allowed, e.g. You can enforce HTTP internally, but HTTPS externally with:
[Restrict(EndpointAttributes.Secure | EndpointAttributes.External,
EndpointAttributes.InSecure | EndpointAttributes.InternalNetworkAccess)]
public class SslExternalAndInsecureInternal { }
Note: each environment is combined with Enum flags and delimited with a ,.
But it doesn't let you distinguish between debug and release builds, to enable this you would need to use C# conditional compilation symbols.
E.g only allow HTTP for Debug builds and HTTPS for production Release builds:
#if DEBUG
[Restrict(EndpointAttributes.InSecure)]
#else
[Restrict(EndpointAttributes.Secure)]
#endif
public class MyRequestDto { ... }

Add WebRole.cs - and have it called - in an existing ASP.NET MVC site converted to web role

I have an ASP.NET MVC 4 site running perfectly well in an Azure WebRole. The ASP.NET MVC project was started on its own, after which I added an Azure Cloud Service project to the solution and added the ASP.NET project/site as one of the 'roles' of the service (so it shows up in the 'Roles' folder).
My problem is that I would like to have working a WebRole.cs file within the ASP.NET MVC project, but no matter what I've tried to do, it appears that when deployed, it just never gets called. OnStart and the override of Run (which I know, must never leave the loop) -- these just apparently never get called.
But if you startup a new CloudService project and add, at that time from the start, an ASP.NET MVC project, it automatically has a WebRole.cs file in it, so my guess is that I need to configure something somewhere for the WebRole.cs (actually speaking, the WebRole class, which inherits RoleEntryPoint) to get called. What might that be?
using System;
using System.Web;
//using Microsoft.WindowsAzure.StorageClient;
using System.Diagnostics;
using System.Threading;
namespace Us.WebUI
{
public class WebRole : Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint
{
public override bool OnStart()
{
return true; //return base.OnStart(); // CALL THIS???
}
public override void Run()
{
while (true) {
Thread.Sleep(TimeSpan.FromSeconds(30));
try {
EmailFuncs.SendEmailToUs("An email from our WebRole?????", "Email me this, email me that.");
}
catch { }
}
}
}
}
UPDATE: Thanks, the question has been answered. But I will add: On doing this, while it clearly was working (fully deployed and in emulator), that suddenly I was having problems doing a full publish of the site. After a azure publish took 3 hours:
Verifying storage account 'xyz'... > Uploading Package... > - Updating... [stayed here for 3 hours], it failed with this error: The server encountered an internal error. Please retry the request. So one thing I was wondering is, did I need to override OnStop in WebRole.cs?
UPDATE 2: Those previous problems were fixed, and had nothing to do with this issue. Actually, I've learned this: If you ever have any warnings generated in your build, Azure often will not work with them even when they don't cause problems locally or in other hosts. Since then, I've been much more studious to tackling build warnings (but critical to this is turning off with warning codes the many warning types you want to ignore!).
Adding a class to your Web Project which inherits from RoleEntryPoint is sufficient, it should just work. Did you try setting a breakpoint in the emulator?
What you might be experiencing is that EmailFuncs.SendEmailToUs requires info from the app/web.config and that this info is not available. You need to know that your WebRole class runs in a different process (not your web application), meaning it's not using your web.config. If you want the WebRole.cs to read info from the configuration file, you'll need to add these settings in WaIISHost.exe.config

Biztalk Log4Net [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Has anyone used log4net with Biztalk? We are currently looking into using it and are trying to access pros/cons, and whether or not it would meet our needs.
I have used Log4Net with BizTalk, but i will say that out of the box i ran into issues. Every call out of BizTalk results in the current orchestration getting dehydrated (serialized) so any type you use in BizTalk would have to be serializable and the log4net logger was not.
If you absolutely have to use log4net there is a wrapper that Scott Colestock wrote here.
Assuming you are not locked in, i would just use Enterprise Logging, it offers almost the same functionality as log4net and works out of the box with BizTalk. You can find it here.
For pros and cons, i will say that offer almost exact functionality, I actually ended up creating a wrapper utility that made the Enterprise Library Logging Block look more like log4net.
public static class Logging
{
public static void LogMessage(TraceEventType eventType, string category, string message)
{
LogEntry logEntry = new LogEntry();
logEntry.Severity = eventType;
logEntry.Priority = 1;
logEntry.Categories.Add(category);
logEntry.Message = message;
Logger.Write(logEntry);
}
public static void LogError(string category, string message)
{
LogMessage(TraceEventType.Error, category,message);
}
public static void LogInfo(string category, string message)
{
LogMessage(TraceEventType.Information, category, message);
}
public static void LogVerbose(string category, string message)
{
LogMessage(TraceEventType.Verbose, category, message);
}
}
And if you need more look here .
Have you considered using ETW. This in my opinion is the way to go for instrumenting BizTalk. http://blogs.msdn.com/b/asgisv/archive/2010/05/11/best-practices-for-instrumenting-high-performance-biztalk-solutions.aspx
One of the drawbacks of using both log4net and Enterprise Logging is you need config to enable it. So you have to manage the btsntsvc.exe.config files on all servers in your biztalk group which can be an overhead.
ETW is zero config.
I've got to say that after using both log4net and MS Enterprise Library for application logging on different projects, I prefer log4net. I particularly like the way that with log4net you can centralise the configuration in a single place (e.g. database), rather than having to rely on local server app.config for the btsntsvc.exe.
This is particularly useful if you need to spin out new server instances to add to your farm - you've got enough to do without worrying about logging config. I've used log4net with both BTS2004 and BTS2006R2 and been satisfied. One thing I would recommend whichever logging framework you go with, don't fall into the trap of using the Event Log as a sink - when you scale out across 10 BTS app servers, it is a time consuming process to track errors, particularly as orchestration instances have no affinity to an app server and tend to move across your estate! Keep the event log for crucial OS and BTS service issues, rather than custom application errors - makes SCOM monitoring a lot less painless.
FYI - I too use log4net with Colestock's serializable wrapper, albeit with a few tweaks.

Resources