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.
Related
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.
I am trying to use Coded UI compiled Dlls in Selenium project.
I Created on Class Library Project in Visual Studio where I created on class in this i write one simple method to draw highlight the "Save as window" like:
namespace CreadeDll
{
public class Class1
{
public void ValidateSaveasWidnow()
{
WinWindow window = new WinWindow();
window.SearchProperties.Add(WinWindow.PropertyNames.ControlType, "Window");
window.SearchProperties.Add(WinWindow.PropertyNames.Name, "Save Print Output As");
window.DrawHighlight();
}
}
}
After Build the application, i added this DLL in my selenium (C#, which is different project) project through reference.
namespace SeleniumProj
{
[TestFixture]
public class TestDll
{
[Test]
public void gets()
{
CreadeDll.Class1 c = new CreadeDll.Class1();
c.ValidateSaveasWidnow();
}
}
}
But the problem here is i am unable to Build. When i try to run it is giving message like "There were build errors"
Coded UI is available only in enterprise license of Visual Studio. Also VS 2019 will be the last version of Visual Studio that contains the Coded UI test functionality as Microsoft is deprecating the coded UI from later version onward. For more detail on this please follow this link .
I would suggest to go for appium Winappdriver to solve your windows UI control problem.
You can get appium winappdiver from this link : https://github.com/Microsoft/WinAppDriver
To learn more about WInappdriver you can refer the below links:
Winappdriver 8 minutes overview with demos
C# demo with calculator sample walkthrough
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 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
Environment: WPF, .NET 4.0, VS 2010
I am developing an application which has one main app that will internally invoke sub application and the solution structure (mentioned only the required projects for simplicity) is as below:
Solution.sln
MainApp (WPF application)
SubApp (wpf application)
Assets (class library)
I have added reference to the Assets project into MainApp and SubApp. I added Setup project and:
Added MainApp primary output (this detects Assets.dll as a dependency).
Created a folder SubApp (right click Application Folder and add new folder) and added SubApp primary output inside this folder). This too detects Assets.dll as dependency (which is correct!)
When I build the setup project, run the MSI and install the application, I see target application folder (c:\program files\default company) structure as below:
MainApp
- MainApp.exe
- Assets.dll
- SubApp (folder)
- SubApp.exe
- Assets.dll (I don't want this to appear here simply because there will be SubApp1, SubApp2 and so on in future who all will refer to the same assets dll)
How can this be achieved? I am sorry if question has become too long but I believe in explaining things in one shot than to provide information in bits and pieces.