Month: May 2024
Why does Matlab state that I do not have a valid license file?
For about a week, Matlab has occasionally thrown up a window stating that I do not have a valid license. It went away without any issues, but after the most recent reboot I can’t start matlab. I only get an error window stating that "You do not have a valid license file. To troubleshoot, click "Help"."
Clicking the button leads to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
It appeared the first time when running experiments using the parallel toolbox, But, to be exhaustive: I have no problem with the connectivity, firewall, antivirus, and this problem persists despite reboots of both matlab, and the computer.
Following the link regarding the parallel toolbox:
https://se.mathworks.com/matlabcentral/answers/1819020-why-do-i-get-error-5005-when-i-try-to-launch-matlab-or-use-parallel-computing-toolbox
It states that I should uninstall, and reinstall, the mathworks service host via the suggested mathworksservicehost_2024.5.0.3_win64_installer.exe. This is not straightforward, as several errors crop up following the suggested link:
https://se.mathworks.com/matlabcentral/answers/1815365-how-do-i-uninstall-and-reinstall-mathworks-service-host
However, after several reboots (where I, among other things, reinstall matlab, and update windows) over several tries, I manage to figure out that if I repeatedly and quickly launch the installation it eventually takes me through the process, allowing me to log in and so on.
I now have a Matlab Connector up and running. But Matlab still won’t launch.
Another error I encountered (somewhere during the process) led me to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
I ensure that Matlab already is whitelisted on the windows firewall, and I add MathWorksServiceHost.exe.
Still not solving the problem, I follow the suggestion to contact you and follow the following instructions to give you the log file:
https://se.mathworks.com/matlabcentral/answers/101927-where-are-the-logs-files-located-for-installation-activation-network-license-manager-and-the-serv
I have zipped the log files (excluding the license manager logs, as those instructions were less straightforward), and attached them.
What do you suggest as the next step?
Thanks for your time, and I hope that you have a great day!
// André Berg (formerly Berglund)For about a week, Matlab has occasionally thrown up a window stating that I do not have a valid license. It went away without any issues, but after the most recent reboot I can’t start matlab. I only get an error window stating that "You do not have a valid license file. To troubleshoot, click "Help"."
Clicking the button leads to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
It appeared the first time when running experiments using the parallel toolbox, But, to be exhaustive: I have no problem with the connectivity, firewall, antivirus, and this problem persists despite reboots of both matlab, and the computer.
Following the link regarding the parallel toolbox:
https://se.mathworks.com/matlabcentral/answers/1819020-why-do-i-get-error-5005-when-i-try-to-launch-matlab-or-use-parallel-computing-toolbox
It states that I should uninstall, and reinstall, the mathworks service host via the suggested mathworksservicehost_2024.5.0.3_win64_installer.exe. This is not straightforward, as several errors crop up following the suggested link:
https://se.mathworks.com/matlabcentral/answers/1815365-how-do-i-uninstall-and-reinstall-mathworks-service-host
However, after several reboots (where I, among other things, reinstall matlab, and update windows) over several tries, I manage to figure out that if I repeatedly and quickly launch the installation it eventually takes me through the process, allowing me to log in and so on.
I now have a Matlab Connector up and running. But Matlab still won’t launch.
Another error I encountered (somewhere during the process) led me to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
I ensure that Matlab already is whitelisted on the windows firewall, and I add MathWorksServiceHost.exe.
Still not solving the problem, I follow the suggestion to contact you and follow the following instructions to give you the log file:
https://se.mathworks.com/matlabcentral/answers/101927-where-are-the-logs-files-located-for-installation-activation-network-license-manager-and-the-serv
I have zipped the log files (excluding the license manager logs, as those instructions were less straightforward), and attached them.
What do you suggest as the next step?
Thanks for your time, and I hope that you have a great day!
// André Berg (formerly Berglund) For about a week, Matlab has occasionally thrown up a window stating that I do not have a valid license. It went away without any issues, but after the most recent reboot I can’t start matlab. I only get an error window stating that "You do not have a valid license file. To troubleshoot, click "Help"."
Clicking the button leads to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
It appeared the first time when running experiments using the parallel toolbox, But, to be exhaustive: I have no problem with the connectivity, firewall, antivirus, and this problem persists despite reboots of both matlab, and the computer.
Following the link regarding the parallel toolbox:
https://se.mathworks.com/matlabcentral/answers/1819020-why-do-i-get-error-5005-when-i-try-to-launch-matlab-or-use-parallel-computing-toolbox
It states that I should uninstall, and reinstall, the mathworks service host via the suggested mathworksservicehost_2024.5.0.3_win64_installer.exe. This is not straightforward, as several errors crop up following the suggested link:
https://se.mathworks.com/matlabcentral/answers/1815365-how-do-i-uninstall-and-reinstall-mathworks-service-host
However, after several reboots (where I, among other things, reinstall matlab, and update windows) over several tries, I manage to figure out that if I repeatedly and quickly launch the installation it eventually takes me through the process, allowing me to log in and so on.
I now have a Matlab Connector up and running. But Matlab still won’t launch.
Another error I encountered (somewhere during the process) led me to:
https://se.mathworks.com/matlabcentral/answers/1815395-why-do-i-receive-error-5201-unable-to-access-services-required-to-run-matlab
I ensure that Matlab already is whitelisted on the windows firewall, and I add MathWorksServiceHost.exe.
Still not solving the problem, I follow the suggestion to contact you and follow the following instructions to give you the log file:
https://se.mathworks.com/matlabcentral/answers/101927-where-are-the-logs-files-located-for-installation-activation-network-license-manager-and-the-serv
I have zipped the log files (excluding the license manager logs, as those instructions were less straightforward), and attached them.
What do you suggest as the next step?
Thanks for your time, and I hope that you have a great day!
// André Berg (formerly Berglund) license, file, service host MATLAB Answers — New Questions
Unable to launch local server from MATLAB 2015a
The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version.The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version. The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version. matlab, web, antique version MATLAB Answers — New Questions
Detecting and correcting electrode problems and static noise in an ECG signal
Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards,Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards, Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards, ecg, signal processing, noises, static_noise, electrodes_problems MATLAB Answers — New Questions
Matlab equivalent to Java bigdecimal rounding of Half_up?
Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round().Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round(). Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round(). round half_up MATLAB Answers — New Questions
How to convert the input bump’s height to force exerted by that bump?
Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model)Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model) Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model) height to force, bump height to bump input force MATLAB Answers — New Questions
Assigning a toolbox license to a floating user
I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date.I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date. I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date. license administration. MATLAB Answers — New Questions
MATLAB GPU UBUNTU 20.04 compatibility CUDA driver
Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance.Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance. Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance. gpu, ubuntu20.04, matlab2024a, matlab2023a, matlab2022a, cuda12.5, cuda12.0, driver550, driver525 MATLAB Answers — New Questions
Matlab Simulink encryption method
Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version.Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version. Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version. matlab, cryptage, aes, protected model, simulink.protectedmodel.createharness MATLAB Answers — New Questions
problem with the intensity in *.spc file tgspcread
I am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an exampleI am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an example I am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an example *.spc files, tgspcread MATLAB Answers — New Questions
Weird button behaviour on Excel worksheet – does not do anything the first time pushed
I created a button on the worksheet (activex) and wrote some VBA code which generates a random number and adds a “Q” to the end of it.
What I noticed is that when I press the button the first time, it does nothing and the second time I click the button, the code gets executed. this is consistent with both buttons. Any idea what I have misconfigured?
I created a button on the worksheet (activex) and wrote some VBA code which generates a random number and adds a “Q” to the end of it. What I noticed is that when I press the button the first time, it does nothing and the second time I click the button, the code gets executed. this is consistent with both buttons. Any idea what I have misconfigured? Read More
Copilot for Sales Adoption Tracking & Success KPIs
As my organization rolls out Copilot for Sales starting with a champions cohort first and then team by team across our sales organization, we’re planning what and how to track our success. There are OOTB reports for M365 Copilot adoption and great reports for D365 Sales usage, but we’re not seeing any unique reports for Copilot for Sales. Has anyone developed best practices or repeatable patterns that could be used for this?
In addition to simple DAU and MAU, we’re planning to track more general RevOps metrics like deal velocity, win rate, lead to opportunity conversion rate, and qualification speed.
As my organization rolls out Copilot for Sales starting with a champions cohort first and then team by team across our sales organization, we’re planning what and how to track our success. There are OOTB reports for M365 Copilot adoption and great reports for D365 Sales usage, but we’re not seeing any unique reports for Copilot for Sales. Has anyone developed best practices or repeatable patterns that could be used for this?
In addition to simple DAU and MAU, we’re planning to track more general RevOps metrics like deal velocity, win rate, lead to opportunity conversion rate, and qualification speed. Read More
Create Email Template with easy filling
Hello everyone!
I have a unique situation that I need help with.
Our salon has regular phone calls with clients and after our phone call we open up an .oft template to send them a confirmation of the procedures they accepted to do and declined to do.
Right now a 2×4 table that holds the questions we are required to ask and we manually type “Accepted or Declined” beside each question.
for example:
Hair Extensions | Declined
Hair Colouring | Accepted
Hair Treatment | Declined
Optimally my vision is that we would have some kind of button system on the right column where the technician would press a button such as “Accepted” or “Declined” and then the field would automatically show only the text.
I uploaded a photo of what I mean. If it started off with showing the multiple options and once an option is selected, that field will display the text for the option.
thank you in advance for all the help!
Hello everyone! I have a unique situation that I need help with.Our salon has regular phone calls with clients and after our phone call we open up an .oft template to send them a confirmation of the procedures they accepted to do and declined to do.Right now a 2×4 table that holds the questions we are required to ask and we manually type “Accepted or Declined” beside each question. for example: Hair Extensions | DeclinedHair Colouring | AcceptedHair Treatment | Declined Optimally my vision is that we would have some kind of button system on the right column where the technician would press a button such as “Accepted” or “Declined” and then the field would automatically show only the text.I uploaded a photo of what I mean. If it started off with showing the multiple options and once an option is selected, that field will display the text for the option. thank you in advance for all the help! Read More
Microsoft lists – data input restrictions based on user permissions
Hello,
I need to create a platform using Microsoft Lists to manage tickets.
The tickets will come from multiple countries, and each user group should only be able to view tickets related to their own country (e.g., users in the UK group should only see tickets related to UK). I understand that I can achieve this using user permissions and Power Automate flows, leveraging a column with the country information.
The issue arises with ticket creation. Only staff from the UK should be able to create tickets with the country set to UK. I need to find a way to prevent users in specific groups from using certain values in a column when entering records.
I have searched for a solution but I am still in the dark.
Can you please suggest a solution?
Hello,I need to create a platform using Microsoft Lists to manage tickets.The tickets will come from multiple countries, and each user group should only be able to view tickets related to their own country (e.g., users in the UK group should only see tickets related to UK). I understand that I can achieve this using user permissions and Power Automate flows, leveraging a column with the country information. The issue arises with ticket creation. Only staff from the UK should be able to create tickets with the country set to UK. I need to find a way to prevent users in specific groups from using certain values in a column when entering records. I have searched for a solution but I am still in the dark.Can you please suggest a solution? Read More
Credentials not recognized.
I’m logged into Azure, I’m logged into O365/M365, I can see my Windows 365 VM, and I can open it (Only in windows, not in the browser) but it fails authentication over and over again.
The ONLY thing I can think of is that we’re using MFA for Azure and Office etc. Am I just up a creek?
I’m logged into Azure, I’m logged into O365/M365, I can see my Windows 365 VM, and I can open it (Only in windows, not in the browser) but it fails authentication over and over again.The ONLY thing I can think of is that we’re using MFA for Azure and Office etc. Am I just up a creek? Read More
Lesson Learned #500: Connection Leaks and Query Execution using HikariCP
Other lesson learned about HikariCP has been when we enabled setLeakDetectionThreshold working on a service request was receiving the following error message: 20:21:42.089 [AppExample-ConnectionPooling housekeeper] WARN com.zaxxer.hikari.pool.ProxyLeakTask – Connection leak detection triggered for ConnectionID:1 ClientConnectionId: b9b5344d-f970-XXX-xxxxxxxxxx on thread main, stack trace follows java.lang.Exception: Apparent connection leak detected at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100)
The learned lesson here was, that, in the context of connection leak detection in HikariCP, it is not only the closing of the connection that matters but also the execution of the query and the handling of associated resources. A connection leak occurs when a connection is acquired from the pool but not returned, which can include not properly closing ResultSet and PreparedStatement objects as well as the connection itself. In this case, I found a query that took more than that this setting.
Considerations for Leak Detection
1. Query Execution:
If a query takes a long time to execute, it can appear as a leak if the execution time exceeds the configured leak detection threshold (leak-detection-threshold).
It is important to optimize queries to ensure they complete in a reasonable time frame.
2. Closing the Connection:
Ensuring the connection is closed after its use is complete, regardless of whether the query was successful or failed.
Microsoft Tech Community – Latest Blogs –Read More
Create a Jenkins pipeline to deploy Desktop Apps as MSIX – Part 2: Packaging a Visual Studio solutio
Parts:
Setup the Jenkins environment: install Jenkins and the required tools.
Packaging a Visual Studio solution: for applications that use Visual Studio IDE, like Windows Forms and WPF.
Packaging a solution developed outside Visual Studio: for applications developed outside VS, i.e., in others IDEs like Eclipse or Visual Studio Code, for Java GUI application.
Packaging using the VB6RegistryTool: despite of the name, the tool can be used by any technology.
1. Visual Studio Solution
In this section it will be demonstrated how to create the Visual Studio solution with a Windows Forms application and the Windows Application Packaging Project project used to generate the MSIX file.
In case you prefer, you can skip this step, since the solution is already available on jenkins_msix repo.
Create the Windows Form application
On Visual Studio 2019, select Create a new project, select the Windows Forms app project template and click Next:
Provide the project name WinForms.App and click Next:
I am choosing the .NET 6.0 framework, but feel free to use any other version. Click on Create:
This is the WinForms project structure. I am using only a PictureBox and a button, but it could be an empty project, as the idea is just to show how to package a WinForm application:
Follows the code-behind:
namespace WinForms.App
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
}
}
So far, the WinForm project is a .NET 6.0 application that depends of the .NET runtime available in the client machine. To remove this dependency, it is possible to publish the project as self-contained where the .NET runtime and runtime libraries are bundled together with the application and third-party assemblies.
Add the following lines to the SelfContained and RuntimeIdentifier to the WinForms.App project file:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
More details at: Trim self-contained deployments and executables
Build the application to ensure that no errors appear.
Create the the Windows Application Packaging project
The next step is adding the Windows Application Packaging Project to the solution.
Right-click on the solution, select Add and click on New Project…:
Select the Windows Application Packaging Project and click Next:
Provide the project name WinForms.Packaging and click Create:
The next step is to provide the target and minimum platform version supported by your application. I am selecting both versions to 19041 to keep it simple, as I need to install the same SDKs on my Jenkins server environment:
In the WinForms.Packaging project, right-click on Dependencies node and click Add Project Reference…:
Select the Windows Application Packaging Project and click Next:
Observe that the WinForms.App project was added to the WinForms.Packaging project:
The Windows Application Packaging Project don’t accept the target Any CPU. Therefore, we need to change the processor target to x86 or x64 for both projects.
Open Configuration Manager, change the Active solution platform to x86, change the WinForms.App and WinForms.Packaging projects to x86:
Build the application to ensure that no errors appear.
Build the application using MSBuild command line
Before creating a Jenkins pipeline, let’s make sure that the MSBuild command line that will be used to build our application is working.
Open the Package Manager Console (you can press CTRL+Q and type package manager console):
Before running the following command, make sure to provide the MSBuild.exe PATH available in your environment:
&”C:Program FilesMicrosoft Visual Studio2022EnterpriseMSBuildCurrentBinMSBuild.exe” /p:AppxBundlePlatforms=X86 /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:AppxPackageSigningEnabled=false
In my case, the msix package file was generated on:
C:githubmsixdemos1_VisualStudioWinForms.AppWinForms.PackagingAppPackagesWinForms.Packaging_1.0.0.0_AnyCPU_Debug_Test
In the next section, it will demonstrate how to build a Jenkins Pipeline for this project.
2. Jenkins Pipeline
Pipeline is a series of tasks required to build, test, and deploy an application.
Create a new job
In the Jenkins Dashboard, click on the Create a job option:
Provide a name for the job, check the Pipeline type of job and click on OK to proceed.
In the pipeline configuration page, check the GitHub Project to specify that this is a GitHub project and provide a GitHub URL:
Scroll down under the Pipeline section and change the definition to Pipeline script from SCM
Provide the Repository URL as well. Because this is a public project, we can skip the credentials:
Scroll-down to the Branches to build section, change the branch name to */main, the Jenkins script path to Jenkinsfile01 and click on Save:
Those actions were needed as we want to use the Jenkins pipeline file available in the main branch of the following repo:
Jenkins Pipeline File
In the previous section it was demonstrated how to setup the Jenkins pipeline to use a Jenkins script file available on our GitHub repository.
Follows the Jenkinsfile01 content:
pipeline {
agent any
environment {
MSBUILD = “C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe”
CONFIG = ‘Release’
PLATFORM = ‘x86’
}
stages {
stage(‘Update manifest version’) {
steps {
powershell ”’
$manifest = “01_VisualStudio\WinForms.App\WinForms.Packaging\Package.appxmanifest”
[xml]$xmlDoc = Get-Content $manifest
$version = $xmlDoc.Package.Identity.Version
$trimmedVersion = $version -replace ‘.[0-9]+$’, ‘.’
$xmlDoc.Package.Identity.Version = $trimmedVersion + ${env:BUILD_NUMBER}
$xmlDoc.Save($manifest)
”’
}
}
stage(‘Build’) {
steps {
bat “dotnet restore 01_VisualStudio\WinForms.App\WinForms.App\WinForms.App.csproj”
bat “”${MSBUILD}” 01_VisualStudio\WinForms.App\WinForms.app.sln /p:Configuration=${env.CONFIG} /p:AppxBundlePlatforms=${env.PLATFORM} /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:AppxPackageSigningEnabled=false”
}
post{
always {
archiveArtifacts artifacts: ‘**/*.msix’, followSymlinks: false
}
}
}
}
}
The pipeline directive is the complete script from beginning to end.
The agent directive instructs Jenkins to allocate an executor and workspace for the entire Pipeline. In our case, we are justing saying it can run on any agent. For example, it could be specified that it could run in a Docker container or run on a specific node.
The environment directive specifies a sequence of key-value pairs which will be defined as environment variables for all steps, or stage-specific steps, depending on where the environment directive is located within the Pipeline.
In our case, it is defined the variables MSBUILD that contains the MSBUILD path, the CONFIG with the value Release and PLATFORM with the value x86. Those variables will be used in the command line used to build our application.
The stages block contains on or more stage block, and each stage is going to have one or more steps. In our case, we have only one stage named Build, that has two steps to restore the dotnet WinForms.App project and to build the solution.
The post section defines the additional step needed to keep the msix file artifact available in our build, as workspace is a temporary directory.
You can find more details about the Jenkins pipeline syntax in the post Getting started with Pipeline.
In addition, there is a great post about how to Creating a Jenkins pipeline for a .NET Core application.
Switch back to Jenkins, click on Dashboard and click on the Visual Studio Solution pipeline:
Click on Build Now to start the build:
The job starts by checking out the source code to next restore and build our solution as defined in the Jenkinsfile01.
After the build is done, the build icon will be green and the msix artifact will be available:
The next post demonstrate how to package an application that not uses the Visual Studio IDE, but that uses the Windows Application Packaging Project to generate the MSIX file.
Microsoft Tech Community – Latest Blogs –Read More
I installed SSMS 2022 express and when I am trying to import data its throwing errors
TITLE: SQL Server Import and Export Wizard
——————————
The operation could not be completed.
——————————
ADDITIONAL INFORMATION:
External component has thrown an exception. (System.Data)
——————————
BUTTONS:
OK
——————————
this is the error
and some more errors also came and I resolved with too much hectic but this error I am not able to with this error
can you anybody help me with this
TITLE: SQL Server Import and Export Wizard——————————The operation could not be completed.——————————ADDITIONAL INFORMATION:External component has thrown an exception. (System.Data)——————————BUTTONS:OK——————————this is the error and some more errors also came and I resolved with too much hectic but this error I am not able to with this error can you anybody help me with this Read More
Migrating our local Active Directory servers to the cloud
Hello
Please i need your help on this issue.
Please what’s involved in migrating our local Active Directory servers to the cloud? Does Microsoft Fast Track assist with AD migration?
Hello Please i need your help on this issue. Please what’s involved in migrating our local Active Directory servers to the cloud? Does Microsoft Fast Track assist with AD migration? Read More
Print queue won’t display active print jobs sometimes on the local Win 11 PC,
We have deployed a Lexmark printer over the network via a Print Server. Users sometimes won’t see the active print jobs when they need to reprint from their local computer which is Windows 11. We tested it on a Win 10 computer and it seems to work fine.
We have deployed a Lexmark printer over the network via a Print Server. Users sometimes won’t see the active print jobs when they need to reprint from their local computer which is Windows 11. We tested it on a Win 10 computer and it seems to work fine. Read More