Port forwarding with WCF vb.net TCP chat app - visual-studio

I created a TCP chat app in Visual Basic C# by this tutorial video, and my friend cant connect to the chat server because he is on an other network. How to fix this? I forwarded the ports, but if I enter not local IP address in App.config it crashes. I need help! I trying to fix this sciene 2 days but nothing, I found nothing about this.
The Server's App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service name="ProvinciaEZChatBySTEVEN_S.ChattingService">
<endpoint address="net.tcp://localhost:9876/ChattingService"
binding="netTcpBinding" bindingConfiguration="" name="ChattingServiceEndPoint"
contract="ProvinciaEZChatBySTEVEN_Interfaces.IChattingService" />
</service>
</services>
</system.serviceModel>
</configuration>
The Client's App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost:9876/ChattingService"
binding="netTcpBinding" bindingConfiguration="" contract="ProvinciaEZChatBySTEVEN_Interfaces.IChattingService"
name="ChattingServiceEndPoint" kind="" endpointConfiguration="" />
</client>
</system.serviceModel>
</configuration>

Related

How do I transform this element in my Web.config?

I've been googling for about half the day here and I'm still just as clueless as when I started on this.
Here's the relevant portion of my Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.2"/>
</system.Web>
-->
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DasExternalFileTransfer.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
I want to replace the fileName value under configuration/nlog/targets/target.
I have tried half a dozen different things in my Web.Dev.config. The latest would be
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<target xdt:Transform="Replace" xdt:Locator="XPath(/configuration/nlog/targets)" />
<target xdt:Transform="Replace" fileName="\\newlocation.ad\location1" />
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
To this point I have seen no effect when I preview my transform in Visual Studio.
I suspect that I am not defining the element in a way that the process can locate it, but I am not sure.
Could someone please help me figure out how to define the element properly so that I can replace the value with a new one? Or am I simply taking the wrong approach?
OK, THINK I'VE FIGURED IT OUT
It appears that the namespaces were tripping me up.
I modified this section of my Web.config
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
Note, I removed xmlns="http://www.nlog-project.org/schemas/NLog.xsd".
Then I modified my Web.Dev.config to
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target xdt:Transform="SetAttributes(fileName)" xdt:Locator="Match(name)" name="logfile" fileName="\\newlocation.ad\location1" />
</targets>
</nlog>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Then, when I preview the transform, I see this as the result <target name="logfile" xsi:type="File" fileName="\\newlocation.ad\location1" layout="${longdate} ${callsite} ${level} ${message}"/>.
I just hope now that the removal of the namespace will not adversely affect NLog, but I'll be testing to determine that.
It appears that the namespaces were tripping me up.
I modified this section of my Web.config
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
Note, I removed xmlns="http://www.nlog-project.org/schemas/NLog.xsd".
Then I modified my Web.Dev.config to
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target xdt:Transform="SetAttributes(fileName)" xdt:Locator="Match(name)" name="logfile" fileName="\\newlocation.ad\location1" />
</targets>
</nlog>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Then, when I preview the transform, I see this as the result <target name="logfile" xsi:type="File" fileName="\\newlocation.ad\location1" layout="${longdate} ${callsite} ${level} ${message}"/>.
I just hope now that the removal of the namespace will not adversely affect NLog, but I'll be testing to determine that.

How to prevent web.config reverting during publish to azure from Visual Studio

When I publish my .net core app to azure, the web.config seems to revert to something else and I can't figure out why.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000" maxUrl="102410" maxQueryString="204810" />
</requestFiltering>
</security>
<applicationInitialization>
<add initializationPage="/" />
</applicationInitialization>
</system.webServer>
</configuration>
But what arrives on the server is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.UI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
The security and appinitialization sections completely disappear. What's going on here?

Spring boot on Azure produces internal server error

I want to deploy my jar on microsoft azure but it shows me an internal server error. the jar works on my pc fine, i added the following web.config file to my wwwroot:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar ";%HOME%\site\wwwroot\myjar.jar";">
</httpPlatform>
</system.webServer>
</configuration>
Unfortunately it does not work... I want to deploy it on a webApp in azure
It was a non-well formated xml file... now it works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar %HOME%\site\wwwroot\myjar.jar" >
</httpPlatform>
</system.webServer>
</configuration>

VS 2013 Not Obeying Nuget Configuration in AppData

I have a file in %appdata%/nuget/nuget.config with following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="C:\BTR\packages" />
</config>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</activePackageSource>
</configuration>
Then in a project, I have the following in a packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net35" />
</packages>
If I delete the Newtonsoft dll from /bin and rebuild, I would expect it to download the package to c:\btr\packages, but it downloads it to \packages in same folder as solution.
Any ideas why this isn't obeying the setting? I don't (to my knowledge) have any other Nuget.config files anywhere that would override this setting.
Thanks in advance.
UPDATE : See Matt Ward's comment below.

Combining web.config files

Need some help combining these if you can, please.
One is to allow .html and .htm files to act like .asp files for some includes and the other is for custom 404 pages.
I've tried all sorts of variations, but everything apart from using the files separately gives me a '500 - Internal Server Error' message.
web.config 1:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
web.config 2:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>
This should work. Check parent web.config files and look for issues cause by inheritance.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>

Resources