I'm working with the ABP Framework and I'm implementing my own mail templates.
The project was made using the abp project template. I created the template in my Application module: Acme.Bookstore.Application/Assets/Templates/MyEmailTemplate.tpl. I edited the properties of the file to be embedded.
Then I made an instance of the template definition provider as follows:
public class MyEmailTemplateDefinitionProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(
new TemplateDefinition(
MyEmailTemplates.MyEmailTemplate,
displayName: LocalizableString.Create<AccountResource>($"TextTemplate:{MyEmailTemplates.MyEmailTemplate}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(AccountResource)
).WithVirtualFilePath($"Assets/Templates/MyEmailTemplate.tpl", true)
);
}
}
Then I added the following lines to my BookstoreApplicationModule.cs
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<BookstoreApplicationModule>("Acme.Bookstore");
});
I did all this following this documentation: https://docs.abp.io/en/abp/5.3/Virtual-File-System
When debugging locally all works well, but when I deploy the project it can't access the template file. The error is as follows:
Volo.Abp.AbpException: Could not find a file/folder at the location: Assets/Templates/MyEmailTemplate.tpl
I already tried adding the AddEbedded call in the HttpApi.Host module but got the same result. I don't know what I'm missing.
For the record, I'm deploying in an Ubuntu server, but that shouldn't matter.
The problem was that the embedded files weren't being added to the VirtualFileSystem. It worked in develpment because the framework calls:
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
... Some code ...
options.FileSets.ReplaceEmbeddedByPhysical<BookstoreApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Acme.Bookstore.Application"));
});
}
So the problem didn't arise until I did a dotnet publish.
I could not figure out why it wasn't working on the Application module but moving the files to the Domain.Shared module fixed it.
I guess that there is some package or setting missing on the other module but this solution is enough for me.
Related
Is it possible to create a package more likely a framework package for a modern(phone) and classic(desktop) theme? My question is similar to this one.
I tried creating a package with a classic folder (following this post package.json) then I tried to use Ext.require to call and render views on-demand.
Code:
let command = Ext.String.format(
'{0}.classic.src.view.{1}.{2}View',
namespace,
screen.toLowerCase(),
screen
);
Ext.require(command, function () {
console.log('hello');
xtype = screen.toLowerCase() + 'view';
if (!menuview.getStore()) {
console.log(
'Store not yet available from viewModel binding for ' + screen
);
return;
}
if (!centerview.getComponent(xtype)) {
centerview.add({
xtype: xtype,
itemId: xtype,
heading: node.get('text'),
});
}
centerview.setActiveItem(xtype);
menuview.setSelection(node);
vm = me.getViewModel();
vm.set('heading', node.get('text'));
});
Let's say I have a DashboardView.js on my package, and when I tried to call that on Ext.require, it fails to load the file. I am wondering what am I missing to render my views on-demand.
Hoping to find an answer here. Thanks!
This is called a universal application. There is a really detailed guide showing how you structure and build your application. You end up with two apps... one is classic and one is modern... but you can have shared files like controllers and viewmodels. You can also do this just with modern and use profiles to change xtypes based on phone, tablet or PC. Universal App Guide
You can generate a default starter application that build the directory structure and also the build scripts. It is really very nice. This is the crux behind the model view controller. YOu put the data is the viewModel, the rules/events are in the viewController and all your view classes can be based on the device.
This will build a universal app sample.
sencha -sdk /home/XXX/sencha-sdks/ext-7.3.0 generate app --ext MyApp ./MyApp
if this is in /home/XXX/work/MyApp enter this into your browser:
To run the classic app:
/home/XXX/work/MyApp/index.html?profile=classic
To run the modern app:
/home/XXX/work/MyApp/index.html?profile=modern
Not sure if this answers your question.... I hope it does.
Good day.
I have created a .NetCore2 webapp and would like some guidance on how you get
windows.forms working on it. (VS2017)
This is the error I get basically:
Dot Net Core and Azure Storage: Could not load file or assembly System, Version=4.0.0.0
Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
The project builds but the moment I call the api it fails to detect the dll. (In code it detects the dll fine)
I have added the dll to the project, also followed the instructions of adding it to your project.json. (in my case: package.json)
"frameworks": {
"netcoreapp1.0": {
"imports": [
"net46",
"net40"
]
}
},
Also added the required references to my csproj folder.
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.3</TargetFrameworks>
</PropertyGroup>
How to use System.Windows.Forms in .NET Core class library
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
},
"net40": {
"frameworkAssemblies": {
"System.Windows.Forms": {}
}
}
}
I am still getting the same error.
I know it is not advised to use .Net framework in a .NetCore app.
Am I going to have to port the framework app so it works in a Core enviroment?
The reason i want to just use .NetFramework is that the app already works fine, I just have to get the screens shown to the user.
I also read somewhere that Windows.Forms is not supported with .NetCore in some versions of the framework.
If so, any links to help with this?
I am quite a noob with .NETCore so some of my questions might not make sense or are ignorant.
Thanks
For an unknown reason, when I tried to build my Google App Engine endpoints, I get these errors in all of the API java files generated by Android Studio:
Error:(400, 5) error: method does not override or implement a method from a supertype
Error:(402, 29) error: cannot find symbol method setBatchPath(String)
I did some initial troubleshooting and found out that there's a Builder class inside the java file and it extends AbstractGoogleJsonClient.Builder. I looked at the source for the Builder class and I cannot find the method.
Why all of the sudden am I getting these errors? Help!
Same thing happened to me this morning.
I resolved it by adding this in my backend project
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
and updating this version in my app gradle file.
implementation('com.google.api-client:google-api-client-android:1.23.0')
Faced the same problem. I upgraded google client libs to 1.23.0 and it worked (earlier was 1.22.0)
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.http-client:google-http-client-android:1.23.0'
We already had these in our backend build.gradle:
dependencies {
compile 'com.google.api-client:google-api-client:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.http-client:google-http-client:+'
compile 'com.google.http-client:google-http-client-android:+'
}
All we needed was adding:
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
But it'd have been nice if Google didn't break our codes every once in awhile out of the blue and wasting hours of development time!
For https://github.com/StackExchange/StackExchange.Precompilation:
We have some shared views in separate library where we have installed StackExchange.Precompilation. We have to load those views along with the normal web project's views. We have the latest version of StackExchange.Precompilation installed from NuGet in both projects. I am doing the assembly loading like this:
// Register precompiled view engine
ViewEngines.Engines.Clear();
List<Assembly> viewAssemblies = new List<Assembly> { typeof(HomeController).Assembly };
viewAssemblies.AddRange(AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.ToLower().Contains(".web")));
Log.Debug().Message("Looking for views in: {0}", string.Join(", ", viewAssemblies.Select(a => a.FullName))).Write();
ViewEngines.Engines.Add(new PrecompiledViewEngine(viewAssemblies.ToArray()));
In the web project, we return views the normal way: return View("Index");
When using PrecompiledViewEngine we get an error when trying to render relative names like that:
The view 'Index' or its master was not found or no view engine supports the searched locations.
The following locations were searched:
~/util/Views/Example/Index.cshtml
~/util/Views/Shared/Index.cshtml
util is the alias of the application in IIS. We don't have any areas registered.
When I copied the PrecompiledViewEngine class from GitHub - it worked! Am I missing something that will make the version distributed through NuGet work?
Copying the code over turned out not to work. I must have been trying something else at the time that made it work for that specific case.
The problem is actually a bug in StackExchange.Precompilation. I've created an issue there: https://github.com/StackExchange/StackExchange.Precompilation/issues/12
Here's my solution architecture:
VM (class lib) => references SQLite.
App (WPF Desktop App) => references VM.
VSIX (Visual Studio extension) => references VM.
I have copied EF providers related stuff from app.config of VM project to both desktop app and VSIX projects. The desktop app works fine whereas the VSIX project throws the following exception:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite.EF6'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
Is there something special I need to do in case of extension projects?
Adding the last line in the following class fixed it for me:
public class SQLiteConfiguration : DbConfiguration
{
public SQLiteConfiguration()
{
SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);
SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
SetProviderServices("System.Data.SQLite", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));
SetProviderServices("System.Data.SQLite.EF6", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));
}
}
Not sure why this exception was only being thrown in VSIX project, and not the desktop app.
Might help someone down the road.