Generate automatic logs when entering and exiting functions .net 2.0 - .net-2.0

I am using .net 2.0. I want to generate the logs when the methods are calling (before call and after call) in a particular class. Is it possible in Enterprise Library 2.0 or log4net? or Is there any other way?

The simplest approach would of course be to just add code to each method. I assume that you do not want to do that.
You should be able to accomplish this with the Policy Injection Application Block, introduced in Enterprise Library 3.0 or the Unity Application Block, introduced in Enterprise Library 4.0. I don't think there is anything built into Enterprise Library 2.0 that would be helpful. I have never used log4net, but I doubt that it has any features that would help either.
You could also look into aspect oriented programming tools, like PostSharp.
Here is an article on how to accomplish this with Unity.

Related

Compile Swift to WebAssembly

The LLVM infrastructure now supports compiling from LLVM IR to WebAssembly (at least experimentally). Swift uses the LLVM compiler infrastructure and can easily be compiled to LLVM IR. So I thought it would be straightforward to compile some Swift code to LLVM IR and then to WebAssembly.
It turned out not to be that easy, however. It looks like LLVM IR is not entirely platform independent? Whatever the reason behind the scenes, when compiling Swift to LLVM IR, a target architecture must be specified and WebAssembly is not available.
I have two questions then:
1) Am I correct that there is currently (as of October 2017) no way to compile Swift to WebAssembly?
2) What would it take to make WebAssembly a supported target for Swift to LLVM IR compilation?
1) To the best of my knowledge as of early Nov, 2017 you are correct: there is no commonly available way to compile Swift to WebAssembly. Maybe some enterprising hacker somewhere has made it happen but if so she hasn't shared her code with us yet.
2) In order to enable Wasm support you will probably need to hack on a few different parts. I think you could do it without knowing much of anything about the internals of the compiler (e.g. the parser & optimizers), but you'd need to learn about how the toolchain works and how it integrates with the platform at runtime.
You can learn a ton about what you'd need to do by studying how Swift was ported to Android. Luckily, Brian Gesiak posted a really detailed blog post about exactly how that port worked (warning: small Patreon donation required):
https://modocache.io/how-to-port-the-swift-runtime-to-android
Seriously, you would be nuts to embark on this project without reading that article.
Though I'm NOT an expert, based on that port and my (basic) understanding of Swift, I think the rough overview of where you'd need to hack would be:
The Swift compiler
You'll need to teach it about the Wasm "triple" used by LLVM, so it knows how to integrate with the rest of its toolchain
You'll need to set up a WebAssembly platform so that people can write #if os(WebAssembly) in places that require conditional compilation
You'll also need to set up similar build-time macros. The Android article explains this sort of thing really well.
The Swift runtime
This is written in C++ and it needs to run on Wasm
Since Wasm is an unusual platform there will probably be some work here. You might need to provide compatibility shims for various system calls and the like.
Projects like Emscripten have demonstrated lots of success compiling C++ to Wasm.
The Swift standard library
In theory you can write & run Swift code that doesn't use the standard library, but who would want to?
Also in theory this should "just work" if the runtime works, but you will likely need to use your #if os(WebAssembly) feature here to work around platform irregularities
Bonus: The Foundation and Dispatch libraries
If you want to use existing Swift code these two libraries will be essential.
Links:
Brian Gesiak's awesome blog post: https://modocache.io/how-to-port-the-swift-runtime-to-android
Link to the Android port's pull request: https://github.com/apple/swift/pull/1442
Interesting article about the challenges and rewards of cross-platform Swift: https://medium.com/#ephemer/how-we-put-an-app-in-the-android-play-store-using-swift-67bd99573e3c
It looks like there is a commercial offering that supports compilation of Swift to WebAssembly. RemObjects, the developer tooling company, has just announced support for WebAssembly with their Elements compiler, which can compile Java, Swift, C# and Oxygene.
As of May 2019 there's an open-source project available called SwiftWasm that allows you to compile Swift code to WebAssembly targeting WASI SDK. This means that binaries produced by SwiftWasm can be executed either in browsers with WASI polyfill or standalone WebAssembly runtimes supporting WASI such as wasmtime, lucet or wasmer.
I was looking for a way to convert Swift code to web assembly, and I found this.
https://swiftwasm.org/
I do not know how mature this platform is (October 2022) and if it can flourish, but having the capability is exciting.
Also, it provides means for writing JavaScript in Swift directly.
WebAssembly target would be like a generic unix target for llvm, so I think someone needs develop that port.
Please note that Swift -> Wasm in browser would be pretty much useless because Wasm has no DOM or DOM API access so you still need JavaScript to do anything meaningful, thus the question: why would anyone bother to make the port? It looks like JavaScript remains the only web language. If you don't like JavaScript you better forget the web development.
Chances are that Swift will run on Android before it runs on the web so stick with Swift/iOS and then make the port to Android whenever that becomes possible. People don't use the web/browser that much anyway.

Are RecordSet Objects Deprecated In .Net 4.5?

Are RecordSet objects deprecated in the .Net 4.5 Framework? If so, is it possible to include them in a .Net 4.5 Framework project by referencing them?
From my reading, I understand them to be deprecated. I also understand that if your "target" framework is higher than that of the desired reference, the reference cannot be included in your solution (the IDE, e.g. Visual Studio 2013, will not allow the inclusion).
I am looking for a definitive, simple answer as none seem to be available elsewhere (though there are certainly troves of information on the web about RecordSet and DataSet). Again, my question is not how to use RecordSet, but rather whether it is deprecated and - if so - how to include in a .Net 4.5 Framework solution (which I am under the impression is not possible).
If you are able to attach any references, that would be awesome. I am either trying to prove me "wrong" or someone else "wrong".
Here is one of the references I have found that seems to suggest RecordSets aren't really a part of the .Net piece.
There has never been a type named "RecordSet" in the .NET Framework. That name was taken, a COM type that had its hay days in the 1990s. Part of DAO and ADO, COM object models that made it easy to access data. And found its way into plenty of .NET programs, stuck on data providers of the 1990s or injected by code originally written in VB6 or VBA, the most popular programming tools in the 90s.
No, it is alive and well, ADO is not deprecated. DAO got the axe 13 years ago when Jet was removed from the standard distribution. Albeit that it seems to be not quite dead, it is still included with every current Windows version. Microsoft code never dies. COM interop in .NET 4.5, what you use under the covers to consume the ADODB type library, has not changed at all.
There was an ill-fated attempt to make ADO more compatible with 64-bit code, fixing a bug in the type library. Released in Windows 7 SP1, it caused wide-spread dismay and misery so was canceled again. Hopefully you don't have that viral problem.
Otherwise typical of software, it is not like fine wine, it does not age gracefully. Still using Recordset today does not make sense, you'd at least consider uplifting to the System.Data.Oledb namespace. Which is the managed .NET wrapper around ADO.

Script hosting in .Net 4.5

We were using IronRuby in our applications for some simple scripting of biz logic and rules.
We are trying to upgrade everything to .NET 4.5 - and our ScriptRuntime/IronRuby code is not happy with that. It does not lok like IronRuby has had a lot of traction lately, so we are wondering what would be a good scripting engine to switch to that is best supported by a .NET 4.5 environment. We prefer simple - the less third-party stuff we have to bring in the better. OUr scripts are also simple - not a big effort to convert.
Suggestions?
If converting your scripts to C# isn't a problem, I would recommend looking into the Microsoft "Roslyn" CTP and its Scripting API.
Because the .NET compiler developers are currently rebuilding their compilers in the Roslyn architecture and the Visual Studio team intends to consume the Roslyn compilers in the future, it's a safe bet that support for this scenario will remain for quite some time.
If you're not looking to consume the Roslyn architecture, you could also leverage Windows PowerShell by writing a custom host application that can execute PowerShell scripts that contain your business logic.

What are the advantages of using Framework over Library or other way round while developing Software?

What are the advantages of using Framework over Library or other way around while developing Web Applications or different types of Software.
I understand using Framework we can make use of basic functionality and then add upon functionality which we require but I am having hard time understanding the advantages of it as if we develop using Library than also we get some basic functionality and then add upon them the functionality as we need and so where in comes the actual advantages of using Framework.
I think it's important to distinguish between a framework and a library when answering.
A framework follows the Hollywood principle: "Don't call us; we'll call you." You plug your code into the framework according to its API. The framework acts as a constraint that solves the particular problem it was designed to solve (e.g., web application development).
A framework will use a combination of your code and 3rd party libraries to solve a particular problem. It will treat your code as one of those 3rd party libraries.
If you eschew a framework, the roles are reversed. Now you and your code are in charge: "I'll do the calling, thank you." A library is a self-contained piece that plugs into the software that you write.
So why prefer a framework? Use one that is written better than the scaffolding that you would be able to write yourself. A framework is likely to be tested more thoroughly and have a wider user base than code you'll write.
You'd write an application without a framework if you're working on a specialized problem, you have deep knowledge of the domain, and there are no frameworks available that demonstrate deeper insight than you have.
A library is just something that solves a problem but it is your job to integrate it the project. Basically it offers some feature that are context-free.
A framework will provide the features plus an infrastructure for them - you will have to develop according to the framework's rules. So you might have less control and freedom but you save time.

Best .NET Framework 2.0 book for C#, Libraries?

I am an senior-slash-"advanced" C#/.NET developer, currently using 3.5 Framework with WPF/WCF and Silverlight (WPF/E). I have come up right through 1.0 and 2.0 and so am well versed with the evolution of .NET. My next project could be "back" into 2.0 Framework, but with enough complexity (and time pressure) so as to call on "expert" skills, not just "advanced" ones.
Thus I am looking for a book with comprehensive coverage of the 2.0 Framework, primarily the organization and use of the libraries (by which, yes, I really just mean "the Framework"...) available in that rev. I want to have a complete, organized reference on hand for what tools are available in the box, so to speak, to choose the right ones at each step and not re-invent any wheels.
I own and love "CLR via C#", but this isn't a question about the CLR, it's about libraries (Framwork) primarily, and also interfacing techniques to .NET-supported related products.
If I "subtract out" my existing 3.0/3.5 knowledge/experience, I might say that I've only ever thoroughly investigated and used some 50-75% of the 2.0 Framework - so what I'd like to see is an authoritative guide to the full 100%. Doesn't need rigorous details or comprehensive examples, but rather a full assessment of scale and scope to be able to design and implement effective solutions in .net 2.0 "the right way".
C# 3.0 in a Nutshell covers parts of the framework in sufficient detail. I find it to be a very useful book to have around.
Programming Microsoft Visual C# 2005: The Base Class Library specifically covers the framework, but in my opinion the Nutshell book is better and you can always find additional information on MSDN.
Windows Forms Programming in C# covers WinForms in detail, or you may want to look at Chris Sells' book on WPF instead. I'm not familiar with the latter, but the first is okay.
It sounds like you have a good grasp on C# itself, so you probably want to know what was in 2.0 that isn't in 3.0 or 3.5. For this reason, you might be interested in some of the following resources, namely the C# 2.0 standard:
ECMA C# 2.0 Standard
C# 2.0 - The Complete Reference
Any of the C# books by Apress
I particularly like the C# 2.0 Complete Reference book, and keep a copy on my desk at home, but the C# 2.0 standard is incomparably good as well; it's just a question of whether you can stay awake long enough to get through any of it. :)
For WinForms programming, the book that has proved itself most useful to me is Windows Forms 2.0 Programming. If there isn't a single book that has everything you're looking for, I think this book would be part of the collection comprising the next best thing.