AngularJS with .NET MVC Bundling Minification Error - asp.net-mvc

I have been developing a large AngularJS application inside of a .NET MVC Website. I've gone way to long without testing if it will sucesfully minifiy using the Bundle Optimiazation Features?
BundleTable.EnableOptimizations = True
And of Course, it fails. I've been playing with the Order I bundle my scripts, and ensuring I am using String Literals for my Controller Names (I wasn't, and that is a lot of re-factoring that I will have to do).
But I can not get my Core Scripts to Minifiy without the angular "Unknown Provider" error.
Here is the exact Error:
Uncaught Error: [$injector:modulerr] [http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ppAccount&p1=Error…redScripts%3Fv%3DknV3wkCOg32ajaw4GwiRSrTXdo8Ue7MRIn65CPYa1b81%3A1%3A379851)]1
Here is my bundle config that is failing:
bundles.Add(new ScriptBundle("~/bundles/PilotPartnerRequiredScripts")
.Include(
"~/UI/js/jquery/jquery-2.1.3.js",
"~/UI/js/plugins/jquery-ui/jquery-ui.js",
"~/UI/js/bootstrap/bootstrap.js",
"~/UI/js/plugins/pace/pace.min.js",
"~/UI/js/plugins/slimscroll/jquery.slimscroll.js",
"~/UI/js/inspinia.js",
"~/UI/js/angular/angular.js",
"~/UI/js/ui-router/angular-ui-router.js",
"~/UI/js/bootstrap/ui-bootstrap-tpls-0.12.1.js",
"~/UI/js/angular/angular-resource.js",
"~/UI/js/angular/angular-sanitize.js",
"~/UI/js/angular/angular-route.js",
"~/UI/js/plugins/switchery/switchery.js",
"~/UI/js/plugins/angular-ui-switch/angular-ui-switch.js",
"~/UI/js/plugins/angularLocalStorage/angular-local-storage.js",
"~/UI/js/plugins/ngDialog/ngDialog.js",
"~/Scripts/ngTags/ng-tags-input.js",
"~/Scripts/uiSortable/sortable.js",
"~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
"~/Scripts/xeditable/xeditable.js"
For the life of me, I can't figure out which dependency isn't being resolved. I feel that if I can narrow it down to a specific dependency I know I can solve the issue.
Is there any way to track down the specific Module that is causing the issue?
Any suggestions on how to make this work?
Thank you for your help.

You should always follow strict di while injecting dependency (Array notation)
Angualar Doc has mentioned that, Do follow strict DI while doing minification, otherwise it could break you app
Eg.(Code)
angular.module('myModule', [])
.factory('serviceId', ['depService', function(depService) {
// ...
}])
.directive('directiveName', ['depService', function(depService) {
// ...
}])
.filter('filterName', ['depService', function(depService) {
// ...
}]);
In above snippet I followed inline array notation of DI, it has been applied on various angular component just to demonstrate it. You should make sure that you follow it wherever you're injecting dependency.

Related

ABP framework: Dashboard not working in some tenants

Dears
I'm facing strange problem here Dashboard not appear in some tenants and works in perfect way in another tenants and host
and this is the error "Uncaught ReferenceError: Chart is not defined"
Can anyone help in this strange error ?
in other tenants this error not appear so it works correctly Please help !!
Abp version 4.2 MVC
It seems ChartJS is missing in your bundle. Probably it might be defined in HostDashboard but not in TenantDashboard.
Make sure ChartjsScriptContributor is added to the page.
<abp-script type="typeof(ChartjsScriptContributor)" />
It's not recommended but you can add it to the global bundle:
Configure<AbpBundlingOptions>(options =>
{
options.ScriptBundles.Configure(
LeptonThemeBundles.Scripts.Global,
bundle =>
{
bundle.Contributors.Add(new ChartjsScriptContributor());
// ...
}
);
});

Properly Load Microsoft.ML model in Xamarin App?

I was learning a bit about how Machine Learning works and eventually built a small C# application because of a tutorial I was watching where a model determines what species of Bee a particular bee IS. It works well in the C# application, but I was also developing an app project that had picture taking capabilities in mind so I thought "No reason the model I saved in the first project can't work in the second, right?". Apparently there is a reason why it can't work because here is the necessary code to view in the app project:
MLContext m_mlObj;
DataViewSchema m_modelSchema;
ITransformer m_loadedTrainedModel;
var folderPath = DependencyService.Get<IFileSystem>().GetExternalStorage();
var fileDir = Path.Combine(folderPath, "trainedModel.zip");
bool testValue = File.Exists(fileDir);
if(testValue)
{
Console.WriteLine("File in fact exists.");
try
{
m_loadedTrainedModel = m_mlObj.Model.Load(fileDir, out m_modelSchema);
}
catch (Exception e)
{
Console.WriteLine("\n\n\nInner exception: " + e.InnerException);
}
}
else
{
Console.WriteLine("File does not exist");
}
I have a breakpoint on the "m_loadedTrainedModel = m_mlObj.Model.Load(fileDir, out m_modelSchema);" line of course and it always triggers an exception.
The exception states:
---> System.TypeLoadException: Could not load type of field 'Microsoft.ML.Transforms.DnnRetrainTransformer:_tfInputShapes' (9) due to: Could not resolve type with token 01000060 from typeref (expected class 'Tensorflow.TensorShape' in assembly 'TensorFlow.NET, Version=0.20.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:TensorFlow.NET, Version=0.20.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd5 1 type:Tensorflow.TensorShape member:(null)
What I THINK this means is it's checking for Tensorflow.TensorShape inside of the package TensorFlow.NET and isn't finding it. If that's the case, I believe I don't have the correct package installed so my Xamarin project will be able to load the model correctly, maybe? Or if not, then what may be the real underlying issue? The code seems straight forward so I'm a bit perplexed as to how this is failing.
If the solution is blatantly going over my head, my apologies and thank you to anyone who is willing to help.
When working with ML.NET on ARM, TensorFlow is one of the limitations at the time of this writing.
https://devblogs.microsoft.com/dotnet/ml-net-june-updates-model-builder/#ml-net-on-arm
What you might want to consider in the meantime is deploying your model as a Web API and making requests to that API from your mobile app.
https://learn.microsoft.com/dotnet/machine-learning/how-to-guides/serve-model-web-api-ml-net

Grails - Including CAS client JAR dependency causes StackOverflowError, logging conflict?

If I include compile "org.jasig.cas.client:cas-client-core:3.3.3" in my BuildConfig.groovy, I get a stack overflow as seen below. If I change compile to runtime the error goes away, but I do have dependencies at compile time as well as runtime.
It looks like some kind of circular reference related to logging, and just getting a stack dump like this isn't helpful. How would I fix it?
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
| Error Error executing script RefreshDependencies: null
You may have multiple versions of log4j-over-slf4j in your dependency chain. If you run 'grails dependency-report runtime', you will see a list of libs that your app sucks in.
Using transitive=false will exclude all dependencies of the lib, but you could try 'exclude "log4j-over-slf4j"' as a more focused exclude if you have multiple slf4j versions in your dependency chain. E.g.,
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
exclude "log4j-over-slf4j"
}
adding transitive=false made the error go away:
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
transitive=false
}
I'm not clear what I needed to exclude specifically, or how anyone could have figured that out from the stack overflow.

Debugging MirrorsUsed

I'm trying to figure out which libraries I need to pass to #MirrorsUsed to get my app compiled and working. Sometimes, it's easy to figure out which library may be missing since a descriptive error is thrown such as Uncaught Unsupported operation: Cannot find class for: NgAttr .
Other times, I get a more obscure message, such as NullError: Cannot call "$gt" on null with no clue as to which library I may be omitting. Is there a better approach to this, besides trial and error?
In case you're wondering, this is an angular app and this is how I currently have it configured:
#MirrorsUsed(targets: const[
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'todo',
'perf_api',
'List',
'NodeTreeSanitizer',
'PlaybackHttpBackendConfig'
],
override: '*')
import 'dart:mirrors';
Use
pub build --mode=debug
this does tree shaking but retains (mostly) the original Dart names.
Then debugging the generated JavaScript usually lets deduce the source of the exception.
EDIT
IMHO these are not necessary anymore, because they were added to #MirrorsUsed in the Angular libs.
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',

Get warnings when programmatically parsing Dart file with analyzer_experimental

I am using analyzer_experimental to parse a Dart file into a CompilationUnit:
import 'package:analyzer_experimental/analyzer.dart';
var unit;
try {
unit = parseDartFile(path);
} on AnalyzerErrorGroup catch(e){
print(e);
}
The above code will catch any parsing errors encountered.
I am also interested in seeing any warnings associated with the file (e.g. 'Undefined name "foo"'). I know that the experimental_analyzer library has the capability to generate these warnings when running from the command line but it does not seem to be possible to get the warnings programmatically, without directly referencing classes in the src folder (which seems like a bad idea).
Is there any way to achieve this?
It's likely this package was very incomplete at the time.
There's now an analyzer package on pub and also a (work-in-progress) STDIN/STDOUT Analyzer Service aimed to help making tooling support easier for IDE extension authors.

Resources