Display upload and download speed values of the device in UWP application[Windows 10 anniversary edition(10.0;Build 14393) ](vb.net) - 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’

Related

Using CefSharp with introp to embed in Microsoft Access Form

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.

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.

Deploying SSRS RDL files from VB.Net - Issue with shared datasources

I am currently developing a utility to help automate our report deployment process. Multiple files, in multiple folders, to multiple servers.
I am using the reportservice2010.asmx web service, and I am deploying my files to the server - so most of the way there.
My issue is that I have shared data sets and shared data sources, which are deployed to individual folders, separate to the report folders. When the deployment occurs the web service looks locally for the data source rather than in the data source folder, giving an error like:
The dataset ‘CostReduction’ refers to the shared data source ‘CostReduction’, which is not
published on the report server. The shared data source ‘CostReduction’ must be published
before this report can run.
The data source/set has been deployed and the report functions correctly but I need to suppress these error messages as they may be hiding other actual errors.
I can hard code a lookup that checks if the data source/set exists and manually filter them via that, but it seems very in-efficient. Is there any way I can tell the web service where to look for these files or another approach that other people have used?
I'm not looking at changing the reports so the data source is read from
/DataSources/DataSourceName
as there are lots of reports and that's not how our existing projects are configured.
Many thanks in advance.
I realize you are using VB, but perhaps this will give you a clue if you convert it from C# to VB, using one of the translators on the web.
Hopefully this will give you a lead in the right direction.
When All the reports in a particular folder, referred to here as the 'parent folder', all use the same Shared Data source, I use this to set all the reports to the same shared Data Source (in this case "/DataSources/Shared_New")
using GetPropertiesSample.ReportService2010;
using System.Diagnostics;
using System.Collections.Generic; //<== required for LISTS
using System.Reflection;
namespace GetPropertiesSample
{
class Program
{
static void Main(string[] args)
{
GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource("0_Contacts"); //<=== This is the parent folder
}
private static void GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource(string sParentFolder)
{
// Create a Web service proxy object and set credentials
ReportingService2010 rs = new ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] reportList = rs.ListChildren(#"/" + sParentFolder, true);
int iCounter = 0;
foreach (CatalogItem item in reportList)
{
iCounter += 1;
Debug.Print(iCounter.ToString() + "]#########################################");
if (item.TypeName == "Report")
{
Debug.Print("Report: " + item.Name);
ResetTheDataSource_for_a_Report(item.Path, "/DataSources/Shared_New"); //<=== This is the DataSource that I want them to use
}
}
}
private static void ResetTheDataSource_for_a_Report(string sPathAndFileNameOfTheReport, string sPathAndFileNameForDataSource)
{
//from: http://stackoverflow.com/questions/13144604/ssrs-reportingservice2010-change-embedded-datasource-to-shared-datasource
ReportingService2010 rs = new ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string reportPathAndName = sPathAndFileNameOfTheReport;
//example of sPathAndFileNameOfTheReport "/0_Contacts/207_Practices_County_CareManager_Role_ContactInfo";
List<ReportService2010.ItemReference> itemRefs = new List<ReportService2010.ItemReference>();
ReportService2010.DataSource[] itemDataSources = rs.GetItemDataSources(reportPathAndName);
foreach (ReportService2010.DataSource itemDataSource in itemDataSources)
{
ReportService2010.ItemReference itemRef = new ReportService2010.ItemReference();
itemRef.Name = itemDataSource.Name;
//example of DataSource i.e. 'itemRef.Reference': "/DataSources/SharedDataSource_DB2_CRM";
itemRef.Reference = sPathAndFileNameForDataSource;
itemRefs.Add(itemRef);
}
rs.SetItemReferences(reportPathAndName, itemRefs.ToArray());
}
}
To Call it I use this in the 'Main' Method:
GetListOfObjectsInGivenFolder_and_ResetTheReportDataSource("0_Contacts");
In this case "0_Contacts" is the parent folder, itself located in the root directory, that contains all the reports for which I want to reset their DataSources to the new Shared DataSource. Then that Method calls the other method "ResetTheDataSource_for_a_Report" which actually sets the DataSource for the report.

twilio nuget package not sending SMS message in vb.net

Does the twilio asp.net helper library package NOT work in vb.net? I can get it to work in c# web app but not vb.net web app.
In a vb.net web application project the following code doesnt send an sms message and when stepping through with the debugger, errs on the send message line and brings up a file dialog asking for access to core.cs. The twilio library's were installed via nuget.
Public Shared Sub SendAuthCodeViaSms(ByVal number As String)
Dim twilioAccountInfo As Dictionary(Of String, String) = XmlParse.GetAccountInfoFromXmlFile("twilio")
Dim accountSid As String = twilioAccountInfo("username")
Dim authToken As String = twilioAccountInfo("password")
If (Not String.IsNullOrEmpty(accountSid) AndAlso Not String.IsNullOrEmpty(authToken)) Then
Dim client = New TwilioRestClient(accountSid, authToken)
client.SendMessage(TwilioSendNumber, ToNumber, "Testmessage from My Twilio number")
Else
'log error and alert developer
End If
End Sub
But in a C# web API project the same code sends the message as expected.
protected void Page_Load(object sender, EventArgs e)
{
const string AccountSid = "mysid";
const string AuthToken = "mytoken";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var message = twilio.SendMessage(TwilioSendNumber,ToNumber,"text message from twilio");
}
and all the sid's and tokens and phone number formats are correct, otherwise the c# one wouldnt send and I wouldnt get to the client.SendMessage part of vb.net version (client.SendSMSMessage produces the same result)
Twilio evangelist here.
I tried our your code by creating a simple VB console app and it worked for me.
The only thing I can think of is that either you are not getting your Twilio credentials correctly when parsing the XML, or the phone number you are passing into the function is not formatted correctly.
I'd suggest putting the result of call to SendMessage() into a variable and checking to see if RestException property is null:
Dim result = client.SendMessage(TwilioSendNumber, ToNumber, "Testmessage from My Twilio number")
If (Not IsNothing(result.RestException)) Then
' Something bad happened
Endif
If Twilio returns a status code greater than 400, then that will show up as an exception in the RestException property and will give you a clue as to whats going on.
If that does not work, you can always break out a tool like Fiddler to watch and see if the library is making the property HTTP request and Twilio is returning the proper result.
Hope that helps.

Read From Text File in Windows 8 Apps/Windows Phone 8 Apps

If I'm going in the wrong direction, please feel free to give me some guidance!
I'm having trouble understanding the use of streams in the Visual Studio for Windows 8 Apps and Windows 8 Phone Apps environment.
All I want to do is read some text from a file into a string. Here's my simple code that I would use for Visual Studio for Windows Desktop:
Sub ReadFromFileTest()
Dim FilePath As String = "c:\2012\Projects\VBDesktopTest\Test.txt"
Dim ReadString As String
Dim Reader As New System.IO.StreamReader(FilePath)
ReadString = Reader.ReadLine()
Do Until ReadString Is Nothing
OutputListBox.Items.Add(ReadString)
ReadString = Reader.ReadLine()
Loop
Reader.Close()
Reader.Dispose()
End Sub
This same code in Visual Studio for Windows 8 Applications generates an error: "value of type 'string' cannot be converted to 'system.io.stream'". I've looked through the list of constructors for the StreamReader class and I see that StreamReader(file name as string) is not supported in ".NET for Windows Store apps". It seems I need to use the StreamReader(stream) constructor but I can't seem to figure out how to make a make my file into a stream.
My ultimate goal is to create a simple app for Windows Phone 7.1 that looks up and returns information from a list of equipment stored in a text file. I'm starting with Windows 8 so as not to further confuse myself with the phone emulator.
See I have no idea of Vb .net But I am sharing the c# code (function) that serves the purpose for windows phone
private string ReadFile(string filePath)
{
//this verse is loaded for the first time so fill it from the text file
var ResrouceStream = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));
if (ResrouceStream != null)
{
Stream myFileStream = ResrouceStream.Stream;
if (myFileStream.CanRead)
{
StreamReader myStreamReader = new StreamReader(myFileStream);
//read the content here
return myStreamReader.ReadToEnd();
}
}
return "NULL";
}
The answer i took is from this link
Reading files from stream windows phone