Configure loopback adapter - c#

Tl;dr How do I access my computer's files using loopbacking?
I need to test my code with a network drive without having one installed. For that, I've installed the Microsoft Loopback Adapter. I can now access it under "Network connections".
Under its properties -> configure -> advanced I've set its network address to 192.168.0.123 .
But it doesn't seem to do anything. I can't, for example, enter that address in a browser or windows explorer and see my computer's files.
How can I achieve that? It doesn't have to be by explorer - if I can do it from C# that's fine because that's the goal anyway.

Thanks everyone. It seems it's trivial (once you know what to do...).
Just use the UNC path. No setup required. (I did share the folder through explorer's UI. But it I'm not sure that was needed.)

Related

Cannot raw print to RDP redirected printer

So I have to RDP into my dev environment. From there, I've been trying to send a file to a Zebra label printer in RAW print mode. Similar to this post, the printer doesn't seem to receive anything. I'm using the same c# example code as a proof of concept. That leas to this, but this is already disabled in my group policies.
I am guessing I am just out of luck and have to copy to local as development occurs, but I was hoping not to have to do that.
We had the same problem on a Windows 2016 Server.
We solved it by changing the value of "Use Remote Desktop Easy printer driver first" in the Group Policy from "Not configured" to "Disabled".
This key is in the folder "Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Printer Redirection configurations".
I'm not sure if on the Computer or User configuration, or on both.
The redirect driver simply doesn't support it.
You can work around it by sharing the printer from your local an adding it that way. Then you can raw print to it.

Can I port my C# (SQL Server) app to a different PC?

I have created a project for my college using C# and with SQL Server 2016 and SQL Server 2017 Management Studio.
It is possible that my teacher would want to test it on a different PC, so how could I run it on different PC?
The database I used was made on a local server in my laptop.
Is it possible to port it to another PC?
Sorry if port is a bad word for this but its the best thing I can come up with.
Click here for image
Port is the wrong word, but I do think I understand what you want to do - "move" the application so he can run it on another endpoint.
Generally speaking:
- The other endpoint will need the same version of .Net you're dependent on
- He will need the same version of SQL Server running on his laptop
Step 1: Create a backup of your database
Instructions are here:
https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/create-a-full-database-backup-sql-server
Step 2: Create an archive (zip/rar, whatever) of Executable
If you haven't compiled it into a standalone EXE and have library dependencies, gather them all (normally in your build directory in your project folder)
Step 3: Move the .bak file and archive to the other computer
Step 4: Restore the database
Instructions are here:
https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/file-restores-simple-recovery-model
Notes:
As Osman Rahimi noted in the comment, you will need to make sure your connection string in your app isn't hardcoded to your IP or machine name. It is best to use localhost or 127.0.0.1 instead.
An alternative you might want to consider is putting the database IP into a variable you load in the .config file. That way you can concatenate it into your connection string and just instruct your teacher to make the change in the config file.
It could also mean you can leave the database on your workstations if it is on the same network and you have nothing blocking the required SQL Server ports between both endpoints.
The salient code/points of reference for the second point above are as follows:
//import statement to reference library
using System.Configuration;
//reference variable in your code (for your connection-string):
ConfigurationManager.AppSettings["SURVEYPATH_SERVER"].ToString()
//where to add variable in config file
<configuration>
<appSettings>
<add key="SQL_SERVER_IP" value="127.0.0.1" />
</appSettings>
</configuration>
To access to database on another machine
Step 1: both machines should be connected to same local network
Step 2: To share database on different machine please refer the following link
https://learn.microsoft.com/en-us/sql/relational-databases/lesson-2-connecting-from-another-computer
I hope this will help you
Simplest you can access it using IP address of your machine to browse it from different machine. make sure your firewall is open or at least the port 80 is open to be able to browse it from outside.
However if you want to copy all code to a different machine and run it from there you have the following options:
1) Do it manually by copying your code and do you configuration there which might take time and might even error prone especially if you miss some configuration. if you just want to copy code only and leave database in your machine, make sure your firewall is open (at least port 1433)
2) Another way if you are familiar with containerization, you can build and share docker's images and then run containers in the other machine easily.
Some articles:
Overview of .NET and Containers
Introduction to SQL Server Containers
Dockerizing Existing .NET MVC
3) Also you can use vagrant as a different solution to share your box and to download it there or through manual virtualization by developing your application from start (Virtualbox, VMware ..etc)

not able to open a file from share drive

I was trying to browse a file(S:\Scalable Development\DRD_ToolPointManagement.doc) from shared location trough web browser using application. when I run my application in local, it is working where as if I push the code to dev and QA environment, not able to open a file
There are two different problems, firstly using a mapped drive and secondly access rights to the folder. Both of these depend upon which account the application is running under. Have a look at http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
You need the built in group IIS_WPG which covers the application pool to have access to the network drive. If the S: drive is not mapped on the web server, you will also need to use the UNC path. If you look in Windows Explorer, your S: drive will appear something like
myshare (\\myserver) (S:) which should be translated to \\myserver\myshare\Scalable Development\DRD_ToolPointManagement.doc
Your domain administrator may need to allow access to the network share, and you may need to consider impersonation
When using the Web browser control, you're using the Internet Explorer. Thus, security settings may apply.
You need to change these in the Control Panel's internet settings of every machine you want to deploy to.
For example you may have to add the location to the trusted zone. Also, the target IE may not be configured to open Office documents in-place.

Simulate a network share in order to share files

Often times a program requires a file that happens to be on a network location. Take for instance Outlook. If I where to place an outlooks database (.pst file) in a network location then windows will make that "transparent" to the user and outlook will still be able to work. Another example could be quickbooks and many more. (as long as you have permissions to write and read)
For this example let's use Microsoft Word. If I would want to open a file in some other computer in the network I would be able to navigate to it as:
and open the file that I want because we are on the same network.
Now my question is how will I be able to simulate that? I want to have a virtual directory on the internet where I can place lets say my .pst file and then select it from windows explorer as:
(this example obviously does not work)
Will it be possible to do that? I believe windows uses a tcp connection with the host computer and then the host responds with he files that it shares. I will like to implement a program that does that so that I could avoid having to create a vpn. Also it will be nice if I could have my pst (outlook database file) on the internet so that all my computers open the same outlook database.
Note my purpose of this question is to open an outlook database file on a network location. I will like to be able to select a file on the internet from windows open file dialog. Also in todays world everything pretty much exists. I will like to create it lol
Windows provides a network redirector for CIFS (Common Internet File System, formerly SMB Server Message Block) resources. Writing a CIFS server is the easiest approach.
But you can also use one of the other existing redirectors, such as NFS, WebDAV, or Netware. And it's also possible to write new redirectors (though that requires kernel mode code, there are some development kits that provide the kernel code for you, similar to a Linux FUSE filesystem).
If you want to avoid writing code, WebDAV over HTTPS will provide you secure access (no need for a VPN layer) and software already exists.
It depends on how the server on the internet is set up to make its files available. Most often tcpip is not the protocol used for this - it is FTP, SFTP, HTTP or something similar. I believe Windows Explorer uses RPC calls over a local network to accomplish this. I don't think you will be able to use the Open File Dialog, you will have to write something similar that works over the protocol you need to use.

Get List of Local Network Computer Names

I am using visual studio 2010 and I have searched on the net for help and other people using the DirectoryEntry("WinNT:") but it doesn't seem to work for me. I can see my network workgroups and if I use DirectoryEntry("WinNT://MYWORKGROUP") I can't see any computers listed.
Please help I am not sure why it isn't working for me.
Thanks
Getting computer names from my network places:
Do not use DirectoryServices unless your sure of a domain environment. The System.DirectoryServices class is an ADSI wrapper that dosent work without an Active Directory to query against. NetServerEnum() works on workgroups and domains but dosen't guarantee the most reliable data (not all machines may show up). It relies on the Computer Browser service.
To browse the local Windows network, NetBIOS name resolution must be running and correctly configured. In a corporate network that often means the presence of a WINS server. The required components are not enabled by default on modern Windows installations.
Before trying to do anything from your own code, ensure that the infrastructure is in place. Open Windows Explorer and expand the "Network" node. If name Windows browsing is correctly you should see the list of computers on the network there. If the list is empty, the problem isn't in your code.

Categories