Using CefSharp with introp to embed in Microsoft Access Form - vba

I have built new C# class library (user control) using CefSharp (it compiles with no errors) to use it in ms access form but when I try to embed in the form i get the following error:
and did not get error all the times, sometimes works fine, and when I try to embed in excel and I get this error:
I developed this library using:
Visual Studio 2013
Dot Net Framework 4.5.2
CefSharp 53.0.0
and this is the main part of my code:
public void InitBrowser()
{
var settings = new CefSettings();
string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (!Cef.IsInitialized)
{
settings.BrowserSubprocessPath = Path.Combine(assemblyFolder, "CefSharp.BrowserSubprocess.exe");
if (Cef.Initialize(settings))
{
browser = new ChromiumWebBrowser("url");
}
}
this.Controls.Add(browser);
browser.Dock = DockStyle.Fill;
}
What is the problem in this scenario?
Thanks in advance.

Related

Display upload and download speed values of the device in UWP application[Windows 10 anniversary edition(10.0;Build 14393) ](vb.net)

With reference to the link https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/ I tried the following methodology. However, I am getting errors. The steps followed are as follows:
Development Environment: Microsoft Visual Studio Enterprise 2017,Version 15.9.23 enter code here
1.Created a console application(c#) that calls an external non visual studio internet speed calculation exe and retrieved the download and upload values and assigned them to ValueSet variables.
Also added ‘AppServiceConnection’ to send the results to UWP based on request from UWP.
static AppServiceConnection connection = null;
connection = new AppServiceConnection();
connection.AppServiceName = "xyz";
connection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName;
connection.RequestReceived += Connection_RequestReceived;
AppServiceConnectionStatus status = await connection.OpenAsync();
private static void Connection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
//added code to call the external exe file
ValueSet valueSet = new ValueSet();
valueSet.Add("Upload", upload);
valueSet.Add("Download", download);
args.Request.SendResponseAsync(valueSet).Completed += delegate { };
}
Note: • Set the output type of the Console Application to -> Properties->Application->outputtype -> WindowsApplication • Target Framework of Console Application : .NET Framework 4.6.1
Created a UWP application
• Added reference to Windows Desktop Extension for UWP. • Added code in Page.xaml.vb (UWP) :On click of Listview link “Calculate Internet Speed”
If(ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0)) Then Await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("Background") End If
• Added following code in App.xaml.vb (UWP)
Protected Overrides Sub OnBackgroundActivated(ByVal args As BackgroundActivatedEventArgs)
MyBase.OnBackgroundActivated(args)
Dim taskInstance As IBackgroundTaskInstance = args.TaskInstance
Dim AppService As AppServiceTriggerDetails = TryCast(taskInstance.TriggerDetails, AppServiceTriggerDetails)
_appServiceDeferral = taskInstance.GetDeferral()
AddHandler taskInstance.Canceled, AddressOf OnAppServicesCanceled
AddHandler _appServiceConnection.RequestReceived, AddressOf OnAppServiceRequestReceived
AddHandler _appServiceConnection.ServiceClosed, AddressOf AppServiceConnection_ServiceClosed
_appServiceConnection = AppService.AppServiceConnection
End Sub
Private Sub OnAppServiceRequestReceived(ByVal sender As AppServiceConnection, ByVal args As AppServiceRequestReceivedEventArgs)
Dim messageDeferral As AppServiceDeferral = args.GetDeferral()
Dim Upload As String = args.Request.Message("Upload").ToString()
Dim Download As String = args.Request.Message("Download").ToString()
messageDeferral.Complete()
End Sub
3)Created a UWP Package: • Applications :Added Console Application( Output type as Windows Application) and UWP application • Package.appmanifest:
• Set the UWP application as Entry Point
Configuration : • UWP package- ‘Deploy’ • UWP application and UWP package – ‘x86’ platform After build, I get the following issues:
.pdb files not loaded
Networkinformationfactory.cpp not found
On reaching this part of code,
Await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("Background")
The following error shows up
‘.WinTypes.pdb not loaded’

Visual Studio is not letting me add CefSharpBrowserControl to a form via the designer

So I decided to try out the CefSharp extension, and what's the first thing I encounter? An error that doesn't let me use the add-on.
This is ridiculously frustrating because I've done every single thing even the administrator or creator has said to do on any forum I've been on. I tried to just compile the source code on the CEFSharp's GitHub, but that didn't work.
If I'm brutally honest, I think that they should just provide a pre-compiled .dll file or group of .dll files that you can just add to the references, instead of just expecting you to do it yourself. It's just a pain, CEFSharp.
I've tried putting the Configuration to x64 AND Any CPU. I've tried making references to several different dlls associated to CEFSharp. I've tried to add the browser element programmatically, and that's worked, but I can't do anything with it (such as execute code when the webpage is done loading). So far none of these solutions have worked at all.
Imports CefSharp
Imports CefSharp.WinForms
Public Class Browser
Dim browser As New _
CefSharp.WinForms.ChromiumWebBrowser("https://google.com/")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles _
MyBase.Load
Me.Controls.Add(browser)
browser.Parent = Panel1
browser.Dock = DockStyle.Fill
End Sub
End Class
Any time I want to add the browser control to my form via the designer toolbox, it won't let me. It keeps showing this error box that says "Failed to load CefSharpBrowser, deleting from the toolbox." Or something along those lines. It's supposed to just be able to drop into the designer, but it's obviously not.
There are similar discussions on CefSharp's google group: Adding CefSharp control to the toolbox and The name "WebView" does not exist in the namespace.
They say that Visual Studio has some limitations when using a mixed mode (C++/CLR) assembly. There is no Visual Studio designer support out of the box in CefSharp. There is some hack about how to do it, but I do not think it worth it to even spend time on it. Most people just accept the fact and move on.
We successfully use CefSharp for one of our projects and we add ChromiumWebBrowser control to a form programmatically, very similar to how you did it in your sample.
I've tried to add the browser element programmatically, and that's
worked, but I can't do anything with it (such as execute code when the
webpage is done loading). So far none of these solutions have worked
at all.
There is a LoadingStateChanged event which you can use to monitor the status of a web browser control. We use it to show progress indication until our web page is fully loaded. Here is how we do it:
private System.Windows.Forms.PictureBox picProgress;
bool loaded = false;
ChromiumWebBrowser browse;
public Main()
{
var uiUrl = "some url or local html file";
browse = new ChromiumWebBrowser(uiUrl);
browse.Dock = DockStyle.Fill;
Controls.Add(browse);
browse.LoadingStateChanged += Browse_LoadingStateChanged;
}
private void Browse_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
{
if (!e.IsLoading)
{
picProgress.BeginInvoke((Action)(() => {
loaded = true;
picProgress.Visible = false;
browse.Visible = true;
}));
}
else
{
browse.BeginInvoke((Action)(() => {
loaded = false;
browse.Visible = false;
}));
}
}
Sorry, it is in C#, but I think you can easily adapt it for VB.net.

sharepoint 2010 GetFolderByServerRelativeUrl not working

version: Sharepoint 2010
Hosted by Apps4rent
with sharepoint 2013 i was able to get folders and files using _api/Web/GetFolderByServerRelativeUrl('') API call
But with sharepoint 2010 instance if i try _api/Web/GetFolderByServerRelativeUrl('') this API it gives 404 error.
Please correct me if i am doing wrong here
Yes. SharePoint 2010 does not support REST API but you can use listdata.svc service.
Refer below code. This should work for you:
'https://abc.abcd.com/sites/RohitW/_vti_bin/Listdata.svc/DocLibTest2?$filter=endswith(Path, 'folder1')'
Note:
Here we are trying to get the files present inside the specific folder(i.e. folder1) of document library(i.e. DocLibTest2)
DocLibTest2 is name of document library.
folder1 is name of folder present inside DocLibTest2
Reference : http://www.sharepointnadeem.com/2012/08/enumerating-items-inside-folder-using.html
SharePoint 2010 not supported to use Rest API in browser directly,please use JSOM to call it:
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getFilesInFolder, 'sp.js');
var files;
function getFilesInFolder() {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var folder = web.getFolderByServerRelativeUrl('/sites/test/Shared%20Documents');
files = folder.get_files();
context.load(files);
context.executeQueryAsync(Function.createDelegate(this, this.OnSuccess), Function.createDelegate(this, this.OnFailure));
}
function OnSuccess()
{
var listItemEnumerator = files.getEnumerator();
while (listItemEnumerator.moveNext()) {
var fileUrl = listItemEnumerator.get_current().get_serverRelativeUrl();
console.log(fileUrl);
}
}
function OnFailure(sender, args) {
alert("Failed. Message:" + args.get_message());
}
</script>

CSS Intellisense not working for MVC 4 project in Visual Studio 2012 Ultimate

Have created a brand new Visual Studio 2012 Ultimate SP2 MVC4 project but unable to get CSS class selector intellisense to work?
When I type <p class="m" .... I should get the class "myClass" appearing in intellisense dropdown but nothing happens.
The file I have listed below is: \Views\Shared\_Layout.cshtml
Any Ideas ?
Edit: Have re-installed VS2012 on brand new windows 7 system (running on Mac OSX parallels 8) and still acting in the same way. Also seems the same for MVC 3 projects.
Extensions installed:
Try adding Web Essentials 2012 extension for Visual Studio 2012: http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6?SRC=VSIDE
And/Or
Try adding Microsoft Web Developer Tools extension.
I have both of these and using your same example the intellisense works like a charm.
I tried all the above mentioned remedies and suggestions. None of these worked in my environment. According to Microsoft (Under Microsoft connect's bug id 781048), they have not implemented CSS class intellisense for MVC/Razor files but are working on including this in a future release.
I have a 10 minute webcast example of extending VS2012 intellisense that adds one solution that will add intellisense to your VS2012 environment: a Visual Studio Intellisense Extension
The webcast uses MEF to extend Visual Studio to add an intellisense completion source that scans the currently loaded project for CSS class names to add as an intellisense completion set. Here is the css completion source class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;
using EnvDTE;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Collections.Specialized;
namespace CssClassIntellisense
{
internal class cssClassList
{
public string cssFileName { get; set; } //Intellisense Statement Completion Tab Name
public HashSet<string> cssClasses { get; set; }
}
internal class CssClassCompletionSource : ICompletionSource
{
private CssClassCompletionSourceProvider m_sourceProvider;
private ITextBuffer m_textBuffer;
private List<Completion> m_compList;
private Project m_proj;
private string m_pattern = #"(?<=\.)[A-Za-z0-9_-]+(?=\ {|{|,|\ )";
private bool m_isDisposed;
//constructor
public CssClassCompletionSource(CssClassCompletionSourceProvider sourceProvider, ITextBuffer textBuffer, Project proj)
{
m_sourceProvider = sourceProvider;
m_textBuffer = textBuffer;
m_proj = proj;
}
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
ITextSnapshot snapshot = session.TextView.TextSnapshot;
SnapshotPoint currentPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);
if (TargetAttribute.Inside(currentPoint))
{
var hash = new List<cssClassList>();
//read any .css project file to get a distinct list of class names
if (m_proj != null)
foreach (ProjectItem _item in m_proj.ProjectItems)
{
getCssFiles(_item, hash);
}
//Scan Current Editor's text buffer for any inline css class names
cssClassList cssclasslist = ScanTextForCssClassName(
"Inline", snapshot.GetText());
//If file had any css class names add to hash of files with css class names
if (cssclasslist != null)
hash.Add(cssclasslist);
var _tokenSpanAtPosition = FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session);
foreach (cssClassList _cssClassList in hash)
{
m_compList = new List<Completion>();
foreach (string str in _cssClassList.cssClasses.OrderBy(x => x)) //alphabetic sort
m_compList.Add(new Completion(str, str, str, null, null));
completionSets.Add(new CompletionSet(
_cssClassList.cssFileName, //the non-localized title of the tab
_cssClassList.cssFileName, //the display title of the tab
_tokenSpanAtPosition,
m_compList,
null));
}
}
}
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session)
{
SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
ITextStructureNavigator navigator = m_sourceProvider.NavigatorService.GetTextStructureNavigator(m_textBuffer);
TextExtent extent = navigator.GetExtentOfWord(currentPoint);
return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
}
private void getCssFiles(ProjectItem proj, List<cssClassList> hash)
{
foreach (ProjectItem _item in proj.ProjectItems)
{
if (_item.Name.EndsWith(".css") &&
!_item.Name.EndsWith(".min.css"))
{
//Scan File's text contents for css class names
cssClassList cssclasslist = ScanTextForCssClassName(
_item.Name.Substring(0, _item.Name.IndexOf(".")),
System.IO.File.ReadAllText(_item.get_FileNames(0))
);
//If file had any css class names add to hash of files with css class names
if (cssclasslist != null)
hash.Add(cssclasslist);
}
//recursively scan any subdirectory project files
if (_item.ProjectItems.Count > 0)
getCssFiles(_item, hash);
}
}
private cssClassList ScanTextForCssClassName(string FileName, string TextToScan)
{
Regex rEx = new Regex(m_pattern);
MatchCollection matches = rEx.Matches(TextToScan);
cssClassList cssclasslist = null;
if (matches.Count > 0)
{
//create css class file object to hold the list css class name that exists in this file
cssclasslist = new cssClassList();
cssclasslist.cssFileName = FileName;
cssclasslist.cssClasses = new HashSet<string>();
}
foreach (Match match in matches)
{
//creat a unique list of css class names
if (!cssclasslist.cssClasses.Contains(match.Value))
cssclasslist.cssClasses.Add(match.Value);
}
return cssclasslist;
}
public void Dispose()
{
if (!m_isDisposed)
{
GC.SuppressFinalize(this);
m_isDisposed = true;
}
}
}
}
As an FYI, you can also address this issue using Resharper. But that is a 3rd party product that needs to be purchased for Visual Studio
Is it just CSS intellisense that's failed or has it completely stopped throughout Visual Studio?
I had a similar issue that effected the whole of my Visual Studio 2012. It was a while back but I remember deleting a folder from my appdata. Take a look at this link, hopefully it will help:
http://www.haneycodes.net/visual-studio-2012-intellisense-not-working-solved/
You are not going to get intellisense for CSS in VS2012 for Razor views. There is a workaround to use intellisense. Just create one test view(.aspx) using ASPX view engine and include your css file there. Now intellisense will work in new aspx view. All you have to do is copy paste the css class from aspx to Razor view(.cshtml or .vbhtml). I hope this helps.

Entity Framework Error in Access VBA - "The specified named connection is either not found in the configuration..."

I have an Access VBA project from where I refer to a COM Interop .TLB written in C#. This C# code simply queries the SQL Server database and returns values via a simple LINQ-to-Entity query.
I'm getting the same error mentioned in this question:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid
However, in my case, it is a Access VBA in a .ADP application that refers to my .Net 4.0 TLB, instead of another .Net project.
I'm aware that if it were another .Net project, I could add the EF connection string XML in its app.config or web.config. But what is the fix if my 'calling' application is Access 2003 VBA?
Here's the VBA code that calls the .Net code
Dim CandidatePassword As String
Dim abc As New MISHash.Password
Dim PasswordStatus As Boolean
CandidatePassword = InputBox("Enter your password")
PasswordStatus = abc.IsValidPassword("myusername", CandidatePassword) ' FAILS HERE
If PasswordStatus Then
MsgBox "Password valid."
Else
MsgBox "Password failed."
End If
Please help. Thank you.
Update: Here is my C# code
using System.Linq;
using System.Runtime.InteropServices;
namespace MISHash
{
public class Password
{
public Password()
{
}
[ComVisible(true)]
public void HashAndSave(string SomePassword)
{
string hashed = BCrypt.HashPassword(SomePassword, BCrypt.GenerateSalt(12));
//save the hashed password in the database
}
[ComVisible(true)]
public bool IsValidPassword(string CandidateUserName, string CandidatePassword)
{
string OriginalHashedPassword;
using (MyDBEntities mycontext = new MyDBEntities())
{
OriginalHashedPassword = (from usr in mycontext.Users
where usr.UserName.Equals(CandidateUserName)
select usr.Password).FirstOrDefault();
}
bool matches = BCrypt.CheckPassword(CandidatePassword, OriginalHashedPassword);
return matches;
}
}
}
See this similar question:
Can I use / access the app.config from .net code, when called via COM
These two seem like your best options:
Manually create a secondary AppDomain
Convert to a VSTO project
Edit
You can also try passing a hard-coded connection string in the constructor:
MyDBEntities mycontext = new MyDBEntities("Server=.\SQLEXPRESS;Database=School;Trusted_Connection=true;Integrated Security=True;MultipleActiveResultSets=True"))